diff options
author | Sebastian Janko <janko.sebastian@gmail.com> | 2019-07-13 02:24:39 +0200 |
---|---|---|
committer | Irina Truong <i.chernyavska@gmail.com> | 2019-07-12 17:24:39 -0700 |
commit | f85642da67285a2b1d991d1d0970d261a715efb1 (patch) | |
tree | 050dffc3887ca2856f7b9fbcb55a761e88578b3f | |
parent | 10cc4ce2b9e1d745f3be91373f48ef6ea9ca7f88 (diff) |
Issue 1019 stacktrace on empty query (#1078)
* Added changes to skip empty queries
Empty queries consist of one or more semicolons
* Reformatted with black
* Added contribution to changelog and name to AUTHORS
* Black.
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | changelog.rst | 2 | ||||
-rw-r--r-- | pgcli/main.py | 2 | ||||
-rw-r--r-- | pgcli/pgexecute.py | 2 |
4 files changed, 7 insertions, 0 deletions
@@ -98,6 +98,7 @@ Contributors: * Telmo "Trooper" (telmotrooper) * Alexander Zawadzki * Pablo A. Bianchi (pabloab) + * Sebastian Janko (sebojanko) Creator: -------- diff --git a/changelog.rst b/changelog.rst index 467afe73..4947bd02 100644 --- a/changelog.rst +++ b/changelog.rst @@ -10,6 +10,7 @@ Bug fixes: ---------- * Error connecting to PostgreSQL 12beta1 (#1058). (Thanks: `Irina Truong`_) +* Empty query caused error message (Thanks: `Sebastian Janko`_) 2.1.1 ===== @@ -993,3 +994,4 @@ Improvements: .. _`VVelox`: https://github.com/VVelox .. _`Telmo "Trooper"`: https://github.com/telmotrooper .. _`Alexander Zawadzki`: https://github.com/zadacka +.. _`Sebastian Janko`: https://github.com/sebojanko diff --git a/pgcli/main.py b/pgcli/main.py index fdbbc15c..27ca09b7 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -859,6 +859,8 @@ class PGCli(object): text, self.pgspecial, exception_formatter, on_error_resume ) + is_special = None + for title, cur, headers, status, sql, success, is_special in res: logger.debug("headers: %r", headers) logger.debug("rows: %r", cur) diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index b3ebb5c0..9e6c4b7c 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -376,6 +376,8 @@ class PGExecute(object): for sql in sqlparse.split(statement): # Remove spaces, eol and semi-colons. sql = sql.rstrip(";") + if not sql: + continue try: if pgspecial: |