From aca84bebb091a51ceeb911249c366e17b954826a Mon Sep 17 00:00:00 2001 From: Jason Kirtland Date: Mon, 30 Mar 2009 20:41:48 +0000 Subject: extract() is now dialect-sensitive and supports SQLite and others. --- lib/sqlalchemy/databases/postgres.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/sqlalchemy/databases/postgres.py') 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) -- cgit v1.2.1