diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-28 23:53:27 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-28 23:53:27 -0400 |
commit | d875f677a3f9c20d49d2569ae6f25beab6ce5f8e (patch) | |
tree | f07528c58da807abd96baeb4eeb9b36ef8e58bcc /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | 1c23741b8e045d266d0ecbed975952547444a5fa (diff) | |
download | sqlalchemy-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 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 22 |
1 files changed, 0 insertions, 22 deletions
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) |