summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorNate Clark <natec425@gmail.com>2019-02-20 12:58:18 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-02-20 18:56:47 -0500
commit8f318692d4443300c90c7be9dc44ae3c8707f818 (patch)
tree3b935eedfd1c31ae4c69c4996f3bae5adec2bd71 /doc
parentd879bed8786b6387b470c148b412731456793653 (diff)
downloadsqlalchemy-8f318692d4443300c90c7be9dc44ae3c8707f818.tar.gz
Include newlines in StatementError formatting
Revised the formatting for :class:`.StatementError` when stringified. Each error detail is broken up over multiple newlines instead of spaced out on a single line. Additionally, the SQL representation now stringifies the SQL statement rather than using ``repr()``, so that newlines are rendered as is. Pull request courtesy Nate Clark. Fixes: #4500 Closes: #4501 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4501 Pull-request-sha: 60cc0ee68dc96b8f483a60d37bcb26b6c6d53efe Change-Id: I79d8418b7495e5691c9a56f41e79495c26a967ff
Diffstat (limited to 'doc')
-rw-r--r--doc/build/changelog/migration_13.rst30
-rw-r--r--doc/build/changelog/unreleased_13/4500.rst13
2 files changed, 43 insertions, 0 deletions
diff --git a/doc/build/changelog/migration_13.rst b/doc/build/changelog/migration_13.rst
index c133bd662..f08c59405 100644
--- a/doc/build/changelog/migration_13.rst
+++ b/doc/build/changelog/migration_13.rst
@@ -1662,3 +1662,33 @@ primary key column::
:ticket:`4362`
:ticket:`4235`
+
+.. _change_4500:
+
+Changed StatementError formatting (newlines and %s)
+=================================================================================
+
+Two changes are introduced to the string representation for ``StatementError``.
+The "detail" and "SQL" portions of the string representation are now
+separated by newlines, and newlines that are present in the original SQL
+statement are maintained. The goal is to improve readability while still
+keeping the original error message on one line for logging purposes.
+
+This means that an error message that previously looked like this::
+
+ sqlalchemy.exc.StatementError: (sqlalchemy.exc.InvalidRequestError) A value is required for bind parameter 'id' [SQL: 'select * from reviews\nwhere id = ?'] (Background on this error at: http://sqlalche.me/e/cd3x)
+
+Will now look like this::
+
+ sqlalchemy.exc.StatementError: (sqlalchemy.exc.InvalidRequestError) A value is required for bind parameter 'id'
+ [SQL: select * from reviews
+ where id = ?]
+ (Background on this error at: http://sqlalche.me/e/cd3x)
+
+The primary impact of this change is that consumers can no longer assume that
+a complete exception message is on a single line, however the original
+"error" portion that is generated from the DBAPI driver or SQLAlchemy internals
+will still be on the first line.
+
+:ticket:`4500`
+
diff --git a/doc/build/changelog/unreleased_13/4500.rst b/doc/build/changelog/unreleased_13/4500.rst
new file mode 100644
index 000000000..9aea02fee
--- /dev/null
+++ b/doc/build/changelog/unreleased_13/4500.rst
@@ -0,0 +1,13 @@
+.. change::
+ :tags: feature, engine
+ :tickets: 4500
+
+ Revised the formatting for :class:`.StatementError` when stringified. Each
+ error detail is broken up over multiple newlines instead of spaced out on a
+ single line. Additionally, the SQL representation now stringifies the SQL
+ statement rather than using ``repr()``, so that newlines are rendered as is.
+ Pull request courtesy Nate Clark.
+
+ .. seealso::
+
+ :ref:`change_4500`