From d875f677a3f9c20d49d2569ae6f25beab6ce5f8e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 28 Jun 2013 23:53:27 -0400 Subject: 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] --- lib/sqlalchemy/dialects/postgresql/base.py | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'lib/sqlalchemy/dialects/postgresql/base.py') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index d69110ebf..6ccf7190e 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1027,28 +1027,6 @@ class PGCompiler(compiler.SQLCompiler): return 'RETURNING ' + ', '.join(columns) - def visit_extract(self, extract, **kwargs): - field = self.extract_map.get(extract.field, extract.field) - if extract.expr.type: - affinity = extract.expr.type._type_affinity - else: - affinity = None - - casts = { - sqltypes.Date: 'date', - sqltypes.DateTime: 'timestamp', - sqltypes.Interval: 'interval', - sqltypes.Time: 'time' - } - cast = casts.get(affinity, None) - if isinstance(extract.expr, sql.ColumnElement) and cast is not None: - expr = extract.expr.op('::', precedence=100)( - sql.literal_column(cast)) - else: - expr = extract.expr - return "EXTRACT(%s FROM %s)" % ( - field, self.process(expr)) - def visit_substring_func(self, func, **kw): s = self.process(func.clauses.clauses[0], **kw) -- cgit v1.2.1