From: Mike Bayer Date: Sun, 17 May 2009 21:54:17 +0000 (+0000) Subject: - Exception messages are truncated when the list of bound X-Git-Tag: rel_0_5_4~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cafc854796e5a095697d577b61dac704b078704;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Exception messages are truncated when the list of bound parameters is larger than 10, preventing enormous multi-page exceptions from filling up screens and logfiles for large executemany() statements. [ticket:1413] --- diff --git a/CHANGES b/CHANGES index ae3a6969bc..4250bfffef 100644 --- a/CHANGES +++ b/CHANGES @@ -134,6 +134,11 @@ CHANGES identifiers, such as 'database.owner'. [ticket: 594, 1341] - sql + - Exception messages are truncated when the list of bound + parameters is larger than 10, preventing enormous + multi-page exceptions from filling up screens and logfiles + for large executemany() statements. [ticket:1413] + - ``sqlalchemy.extract()`` is now dialect sensitive and can extract components of timestamps idiomatically across the supported databases, including SQLite. diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index d1af6d385d..b424b806a1 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -132,6 +132,11 @@ class DBAPIError(SQLAlchemyError): self.connection_invalidated = connection_invalidated def __str__(self): + if len(self.params) > 10: + return ' '.join((SQLAlchemyError.__str__(self), + repr(self.statement), + repr(self.params[:2]), + '... and a total of %i bound parameters' % len(self.params))) return ' '.join((SQLAlchemyError.__str__(self), repr(self.statement), repr(self.params)))