1
0
Fork 0

Fix for #1193 list index out of range on sql comment.

This commit is contained in:
Irina Truong 2020-06-26 13:39:31 -07:00
parent 0c24e8bda2
commit 106c6c7bf8
3 changed files with 3 additions and 2 deletions

View File

@ -13,6 +13,7 @@ Bug fixes:
----------
* Minor typo fixes in `pgclirc`. (Thanks: `anthonydb`_)
* Fix for list index out of range when executing commands from a file (#1193). (Thanks: `Irina Truong`_)
3.0.0
=====

View File

@ -4,7 +4,7 @@ import sqlparse
def query_starts_with(query, prefixes):
"""Check if the query starts with any item from *prefixes*."""
prefixes = [prefix.lower() for prefix in prefixes]
formatted_sql = sqlparse.format(query.lower(), strip_comments=True)
formatted_sql = sqlparse.format(query.lower(), strip_comments=True).strip()
return bool(formatted_sql) and formatted_sql.split()[0] in prefixes

View File

@ -373,9 +373,9 @@ class PGExecute(object):
for sql in sqlparse.split(statement):
# Remove spaces, eol and semi-colons.
sql = sql.rstrip(";")
sql = sqlparse.format(sql, strip_comments=True).strip()
if not sql:
continue
try:
if pgspecial:
# \G is treated specially since we have to set the expanded output.