1
0
mirror of https://github.com/dbcli/pgcli synced 2024-05-31 01:17:54 +00:00

Fix the StopIteration issue in Python 3.7 (#971)

* Fix the StopIteration issue in Python 3.7
This commit is contained in:
Amjith Ramanujam 2018-11-18 20:11:15 -08:00 committed by Irina Truong
parent 923f2d6441
commit 25a66ecfb3
2 changed files with 28 additions and 25 deletions

View File

@ -8,6 +8,7 @@ Bug fixes:
* Set default port in `connect_uri` when none is given. (Thanks: `Daniel Egger`_)
* Fix for error listing databases (#951). (Thanks: `Irina Truong`_)
* Enable Ctrl-Z to suspend the app (Thanks: `Amjith Ramanujam`_).
* Fix StopIteration exception raised at runtime for Python 3.7 (Thanks: `Amjith Ramanujam`_).
Internal:
---------

View File

@ -36,11 +36,11 @@ def extract_from_part(parsed, stop_at_punctuation=True):
for x in extract_from_part(item, stop_at_punctuation):
yield x
elif stop_at_punctuation and item.ttype is Punctuation:
raise StopIteration
return
# An incomplete nested select won't be recognized correctly as a
# sub-select. eg: 'SELECT * FROM (SELECT id FROM user'. This causes
# the second FROM to trigger this elif condition resulting in a
# StopIteration. So we need to ignore the keyword if the keyword
# `return`. So we need to ignore the keyword if the keyword
# FROM.
# Also 'SELECT * FROM abc JOIN def' will trigger this elif
# condition. So we need to ignore the keyword JOIN and its variants
@ -93,7 +93,7 @@ def extract_table_identifiers(token_stream, allow_functions=True):
name = name.lower()
return schema_name, name, alias
try:
for item in token_stream:
if isinstance(item, IdentifierList):
for identifier in item.get_identifiers():
@ -117,6 +117,8 @@ def extract_table_identifiers(token_stream, allow_functions=True):
elif isinstance(item, Function):
schema_name, real_name, alias = parse_identifier(item)
yield TableReference(None, real_name, alias, allow_functions)
except StopIteration:
return
# extract_tables is inspired from examples in the sqlparse lib.