1
1
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:
David Szotten 2016-01-05 16:32:31 +00:00
parent a54830fb65
commit 2b867820d9
2 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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) == []