Commits

Mike Bayer committed 2c7cf22

- 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'"]).

Comments (0)

Files changed (4)

 - 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
 =======
 

lib/sqlalchemy/databases/postgres.py

         return domains
 
 
-
 class PGCompiler(compiler.DefaultCompiler):
     operators = compiler.DefaultCompiler.operators.copy()
     operators.update(
     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),
         }
     )
 

test/base/except.py

                 '', [], 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(

test/dialect/postgres.py

 
 class TimeStampTest(TestBase, AssertsExecutionResults):
     __only_on__ = 'postgres'
+    
+    @testing.uses_deprecated()
     def test_timestamp(self):
         engine = testing.db
         connection = engine.connect()