diff options
author | Rishi Ramraj <thereisnocowlevel@gmail.com> | 2018-05-15 00:35:07 -0400 |
---|---|---|
committer | Rishi Ramraj <thereisnocowlevel@gmail.com> | 2018-05-15 00:35:07 -0400 |
commit | a49f5bdd0f238c84cd6f52f90ec4e661537e8a37 (patch) | |
tree | 16b108a6a0a6a9da065a0c7f673849e26f6ff3ab /pgcli | |
parent | 3869a723652b5bb49048b6bff7903b615aea7e82 (diff) |
Add is_special to run return
Diffstat (limited to 'pgcli')
-rw-r--r-- | pgcli/main.py | 6 | ||||
-rw-r--r-- | pgcli/pgexecute.py | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/pgcli/main.py b/pgcli/main.py index 996afac2..1c04764f 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -286,12 +286,12 @@ class PGCli(object): def execute_from_file(self, pattern, **_): if not pattern: message = '\\i: missing required argument' - return [(None, None, None, message, '', False)] + return [(None, None, None, message, '', False, True)] try: with open(os.path.expanduser(pattern), encoding='utf-8') as f: query = f.read() except IOError as e: - return [(None, None, None, str(e), '', False)] + return [(None, None, None, str(e), '', False, True)] on_error_resume = (self.on_error == 'RESUME') return self.pgexecute.run( @@ -694,7 +694,7 @@ class PGCli(object): res = self.pgexecute.run(text, self.pgspecial, exception_formatter, on_error_resume) - for title, cur, headers, status, sql, success in res: + for title, cur, headers, status, sql, success, is_special in res: logger.debug("headers: %r", headers) logger.debug("rows: %r", cur) logger.debug("status: %r", status) diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 74084fe6..14eb1ed2 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -286,7 +286,7 @@ class PGExecute(object): execute. :return: Generator yielding tuples containing - (title, rows, headers, status, query, success) + (title, rows, headers, status, query, success, is_special) """ # Remove spaces and EOL @@ -307,8 +307,8 @@ class PGExecute(object): try: for result in pgspecial.execute(cur, sql): # e.g. execute_from_file already appends these - if len(result) < 6: - yield result + (sql, True) + if len(result) < 7: + yield result + (sql, True, True) else: yield result continue @@ -316,7 +316,7 @@ class PGExecute(object): pass # Not a special command, so execute as normal sql - yield self.execute_normal_sql(sql) + (sql, True) + yield self.execute_normal_sql(sql) + (sql, True, False) except psycopg2.DatabaseError as e: _logger.error("sql: %r, error: %r", sql, e) _logger.error("traceback: %r", traceback.format_exc()) @@ -325,7 +325,7 @@ class PGExecute(object): or not exception_formatter): raise - yield None, None, None, exception_formatter(e), sql, False + yield None, None, None, exception_formatter(e), sql, False, False if not on_error_resume: break |