summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES12
-rw-r--r--lib/sqlalchemy/databases/postgres.py3
-rw-r--r--test/base/except.py9
-rw-r--r--test/dialect/postgres.py2
4 files changed, 22 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index a2ba1c572..314794b58 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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()