summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-06-28 23:53:27 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-06-28 23:53:27 -0400
commitd875f677a3f9c20d49d2569ae6f25beab6ce5f8e (patch)
treef07528c58da807abd96baeb4eeb9b36ef8e58bcc /test/dialect/postgresql/test_compiler.py
parent1c23741b8e045d266d0ecbed975952547444a5fa (diff)
downloadsqlalchemy-d875f677a3f9c20d49d2569ae6f25beab6ce5f8e.tar.gz
The behavior of :func:`.extract` has been simplified on the
Postgresql dialect to no longer inject a hardcoded ``::timestamp`` or similar cast into the given expression, as this interfered with types such as timezone-aware datetimes, but also does not appear to be at all necessary with modern versions of psycopg2. Also in 0.8.2. [ticket:2740]
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py55
1 files changed, 0 insertions, 55 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index a79c0e7de..11661b11f 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -229,61 +229,6 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
- def test_extract(self):
- t = table('t', column('col1', DateTime), column('col2', Date),
- column('col3', Time), column('col4',
- postgresql.INTERVAL))
- for field in 'year', 'month', 'day', 'epoch', 'hour':
- for expr, compiled_expr in [ # invalid, no cast. plain
- # text. no cast. addition is
- # commutative subtraction is
- # not invalid - no cast. dont
- # crack up on entirely
- # unsupported types
- (t.c.col1, 't.col1 :: timestamp'),
- (t.c.col2, 't.col2 :: date'),
- (t.c.col3, 't.col3 :: time'),
- (func.current_timestamp() - datetime.timedelta(days=5),
- '(CURRENT_TIMESTAMP - %(current_timestamp_1)s) :: '
- 'timestamp'),
- (func.current_timestamp() + func.current_timestamp(),
- 'CURRENT_TIMESTAMP + CURRENT_TIMESTAMP'),
- (text('foo.date + foo.time'), 'foo.date + foo.time'),
- (func.current_timestamp() + datetime.timedelta(days=5),
- '(CURRENT_TIMESTAMP + %(current_timestamp_1)s) :: '
- 'timestamp'),
- (t.c.col2 + t.c.col3, '(t.col2 + t.col3) :: timestamp'
- ),
- (t.c.col2 + datetime.timedelta(days=5),
- '(t.col2 + %(col2_1)s) :: timestamp'),
- (datetime.timedelta(days=5) + t.c.col2,
- '(%(col2_1)s + t.col2) :: timestamp'),
- (t.c.col1 + t.c.col4, '(t.col1 + t.col4) :: timestamp'
- ),
- (t.c.col1 - datetime.timedelta(seconds=30),
- '(t.col1 - %(col1_1)s) :: timestamp'),
- (datetime.timedelta(seconds=30) - t.c.col1,
- '%(col1_1)s - t.col1'),
- (func.coalesce(t.c.col1, func.current_timestamp()),
- 'coalesce(t.col1, CURRENT_TIMESTAMP) :: timestamp'),
- (t.c.col3 + datetime.timedelta(seconds=30),
- '(t.col3 + %(col3_1)s) :: time'),
- (func.current_timestamp() - func.coalesce(t.c.col1,
- func.current_timestamp()),
- '(CURRENT_TIMESTAMP - coalesce(t.col1, '
- 'CURRENT_TIMESTAMP)) :: interval'),
- (3 * func.foobar(type_=Interval),
- '(%(foobar_1)s * foobar()) :: interval'),
- (literal(datetime.timedelta(seconds=10))
- - literal(datetime.timedelta(seconds=10)),
- '(%(param_1)s - %(param_2)s) :: interval'),
- (t.c.col3 + 'some string', 't.col3 + %(col3_1)s'),
- ]:
- self.assert_compile(select([extract(field,
- expr)]).select_from(t),
- 'SELECT EXTRACT(%s FROM %s) AS '
- 'anon_1 FROM t' % (field,
- compiled_expr))
def test_reserved_words(self):
table = Table("pg_table", MetaData(),