diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-05-26 01:00:46 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-05-26 01:00:46 +0000 |
commit | d6b9757778edea97bdbda5c98eb61b37d93296cc (patch) | |
tree | 62e328768bf514963eb40356edf45ec01d20c3b4 | |
parent | 3837a29bfc082b8e718eba007456e3a025238c1d (diff) | |
download | sqlalchemy-d6b9757778edea97bdbda5c98eb61b37d93296cc.tar.gz |
- added unit test for exception formatting
- Deprecated the hardcoded TIMESTAMP function, which when
used as func.TIMESTAMP(value) would render "TIMESTAMP value".
This breaks on some platforms as Postgres doesn't allow
bind parameters to be used in this context. The hard-coded
uppercase is also inappropriate and there's lots of other
PG casts that we'd need to support. So instead, use
text constructs i.e. select(["timestamp '12/05/09'"]).
-rw-r--r-- | CHANGES | 12 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 3 | ||||
-rw-r--r-- | test/base/except.py | 9 | ||||
-rw-r--r-- | test/dialect/postgres.py | 2 |
4 files changed, 22 insertions, 4 deletions
@@ -10,7 +10,17 @@ CHANGES - sql - Repaired the printing of SQL exceptions which are not based on parameters. - + +- postgres + - Deprecated the hardcoded TIMESTAMP function, which when + used as func.TIMESTAMP(value) would render "TIMESTAMP value". + This breaks on some platforms as Postgres doesn't allow + bind parameters to be used in this context. The hard-coded + uppercase is also inappropriate and there's lots of other + PG casts that we'd need to support. So instead, use + text constructs i.e. select(["timestamp '12/05/09'"]). + + 0.5.4p1 ======= diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 068afaf3d..4fc79921b 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -706,7 +706,6 @@ class PGDialect(default.DefaultDialect): return domains - class PGCompiler(compiler.DefaultCompiler): operators = compiler.DefaultCompiler.operators.copy() operators.update( @@ -721,7 +720,7 @@ class PGCompiler(compiler.DefaultCompiler): functions = compiler.DefaultCompiler.functions.copy() functions.update ( { - 'TIMESTAMP':lambda x:'TIMESTAMP %s' % x, + 'TIMESTAMP':util.deprecated(message="Use a literal string 'timestamp <value>' instead")(lambda x:'TIMESTAMP %s' % x), } ) diff --git a/test/base/except.py b/test/base/except.py index 457137c4c..c2b60f32a 100644 --- a/test/base/except.py +++ b/test/base/except.py @@ -25,7 +25,14 @@ class WrapTest(unittest.TestCase): '', [], OperationalError()) except sa_exceptions.DBAPIError: self.assert_(True) - + + def test_tostring(self): + try: + raise sa_exceptions.DBAPIError.instance( + 'this is a message', None, OperationalError()) + except sa_exceptions.DBAPIError, exc: + assert str(exc) == "(OperationalError) 'this is a message' None" + def test_db_error_busted_dbapi(self): try: raise sa_exceptions.DBAPIError.instance( diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py index d613ad2dd..2dfbe018c 100644 --- a/test/dialect/postgres.py +++ b/test/dialect/postgres.py @@ -865,6 +865,8 @@ class ArrayTest(TestBase, AssertsExecutionResults): class TimeStampTest(TestBase, AssertsExecutionResults): __only_on__ = 'postgres' + + @testing.uses_deprecated() def test_timestamp(self): engine = testing.db connection = engine.connect() |