diff options
author | Irina Truong <i.chernyavska@gmail.com> | 2020-06-26 13:39:31 -0700 |
---|---|---|
committer | Irina Truong <i.chernyavska@gmail.com> | 2020-06-26 14:01:24 -0700 |
commit | 106c6c7bf889b0db5fe85eba31f3f7f6b52a0895 (patch) | |
tree | 3dff64c1326922548cb4b1042350cf1bb99a9b4b | |
parent | 0c24e8bda226f3dbd6ccb0381515a9c903847249 (diff) |
Fix for #1193 list index out of range on sql comment.
-rw-r--r-- | changelog.rst | 1 | ||||
-rw-r--r-- | pgcli/packages/parseutils/__init__.py | 2 | ||||
-rw-r--r-- | pgcli/pgexecute.py | 2 |
3 files changed, 3 insertions, 2 deletions
diff --git a/changelog.rst b/changelog.rst index e6f162a8..f2510394 100644 --- a/changelog.rst +++ b/changelog.rst @@ -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 ===== diff --git a/pgcli/packages/parseutils/__init__.py b/pgcli/packages/parseutils/__init__.py index 9bfff73b..a11e7bf2 100644 --- a/pgcli/packages/parseutils/__init__.py +++ b/pgcli/packages/parseutils/__init__.py @@ -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 diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 776c9628..6f7bd715 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -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. |