summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-09-14 16:41:18 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-09-14 16:41:18 +0000
commit3dd5d834ad6d3ae7f515ff20f3b8756d46e2347f (patch)
tree9dda4979252f1fc6017821d2d5a4b392ae5152f4 /lib
parentb8474a4da82e65f06816b3ac1833fd510452d108 (diff)
downloadsqlalchemy-3dd5d834ad6d3ae7f515ff20f3b8756d46e2347f.tar.gz
added extract() function to sql dialect
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/sql.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index ab371dcb9..1f3d3575e 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -10,7 +10,7 @@ from sqlalchemy import types as sqltypes
import string, re, random, sets
types = __import__('types')
-__all__ = ['text', 'table', 'column', 'func', 'select', 'update', 'insert', 'delete', 'join', 'and_', 'or_', 'not_', 'between_', 'case', 'cast', 'union', 'union_all', 'null', 'desc', 'asc', 'outerjoin', 'alias', 'subquery', 'literal', 'bindparam', 'exists']
+__all__ = ['text', 'table', 'column', 'func', 'select', 'update', 'insert', 'delete', 'join', 'and_', 'or_', 'not_', 'between_', 'case', 'cast', 'union', 'union_all', 'null', 'desc', 'asc', 'outerjoin', 'alias', 'subquery', 'literal', 'bindparam', 'exists', 'extract']
def desc(column):
"""returns a descending ORDER BY clause element, e.g.:
@@ -155,7 +155,11 @@ def cast(clause, totype, **kwargs):
"""
return Cast(clause, totype, **kwargs)
-
+def extract(field, expr):
+ """return extract(field FROM expr)"""
+ expr = BinaryClause(text(field), expr, "FROM")
+ return func.extract(expr)
+
def exists(*args, **params):
params['correlate'] = True
s = select(*args, **params)