mirror of
https://github.com/dbcli/pgcli.git
synced 2024-10-06 02:07:53 +03:00
don't error when completing parameter-less functions
This commit is contained in:
parent
a54830fb65
commit
2b867820d9
@ -138,12 +138,12 @@ def parse_typed_field_list(tokens):
|
||||
|
||||
def field_names(sql, mode_filter=('IN', 'OUT', 'INOUT', 'VARIADIC')):
|
||||
"""Yields field names from a table declaration"""
|
||||
|
||||
if not sql:
|
||||
return
|
||||
|
||||
# sql is something like "x int, y text, ..."
|
||||
tokens = sqlparse.parse(sql)[0].flatten()
|
||||
for f in parse_typed_field_list(tokens):
|
||||
if f.name and (not mode_filter or f.mode in mode_filter):
|
||||
yield f.name
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -54,3 +54,7 @@ def test_argument_names():
|
||||
assert list(names) == ['y']
|
||||
|
||||
|
||||
def test_empty_arg_list():
|
||||
# happens for e.g. parameter-less functions like now()
|
||||
names = field_names('')
|
||||
assert list(names) == []
|
||||
|
Loading…
Reference in New Issue
Block a user