diff options
author | Jason Kirtland <jek@discorporate.us> | 2009-03-30 20:41:48 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2009-03-30 20:41:48 +0000 |
commit | aca84bebb091a51ceeb911249c366e17b954826a (patch) | |
tree | 87a0424805905c9fdae0ab6930144c91b9a78ff6 /lib/sqlalchemy/databases/postgres.py | |
parent | 1ad157a0a1823706ffb43ee7d235c38ae16f46ff (diff) | |
download | sqlalchemy-aca84bebb091a51ceeb911249c366e17b954826a.tar.gz |
extract() is now dialect-sensitive and supports SQLite and others.
Diffstat (limited to 'lib/sqlalchemy/databases/postgres.py')
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 038a9e8df..068afaf3d 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -792,6 +792,12 @@ class PGCompiler(compiler.DefaultCompiler): else: return text + def visit_extract(self, extract, **kwargs): + field = self.extract_map.get(extract.field, extract.field) + return "EXTRACT(%s FROM %s::timestamp)" % ( + field, self.process(extract.expr)) + + class PGSchemaGenerator(compiler.SchemaGenerator): def get_column_specification(self, column, **kwargs): colspec = self.preparer.format_column(column) |