projects
/
pgwui_sql
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5615310
)
Fix crash when sql execution error has no line number
author
Karl O. Pinc
<kop@karlpinc.com>
Sat, 21 Sep 2024 18:54:47 +0000
(13:54 -0500)
committer
Karl O. Pinc
<kop@karlpinc.com>
Sat, 21 Sep 2024 18:54:47 +0000
(13:54 -0500)
src/pgwui_sql/views/sql.py
patch
|
blob
|
history
diff --git
a/src/pgwui_sql/views/sql.py
b/src/pgwui_sql/views/sql.py
index c169cea023807b4a27127ed624e43191d698f607..b49256befec8ad4ac214186f7e78edc12f84c746 100644
(file)
--- a/
src/pgwui_sql/views/sql.py
+++ b/
src/pgwui_sql/views/sql.py
@@
-168,11
+168,14
@@
class SQLResultsHandler(pgwui_core.core.SessionDBHandler):
try:
cur.execute(stmt_text)
except psycopg.errors.Error as err:
- lineno = stmt_text.count(
- '\n', 0, int(err.diag.statement_position) - 1) + 1
+ stmt_pos = err.diag.statement_position
+ if stmt_pos is None:
+ lineno = ''
+ else:
+ lineno = stmt_text.count('\n', 0, int(stmt_pos) - 1) + 1
raise sql_ex.ExecutionError(
err.diag.severity,
- lineno,
+ lineno
=lineno
,
descr=err.diag.message_primary,
detail=self.format_detail(err, stmt_text))