summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorPhillip Cloud <cpcloud@gmail.com>2016-05-01 17:56:35 -0700
committerPhillip Cloud <cpcloud@gmail.com>2016-05-01 17:56:35 -0700
commit77fe28546e7124205e50c769f203f8330e35bac7 (patch)
tree3f234d9def153f6358bdd3490081bb5112966e6b /lib/sqlalchemy/sql/compiler.py
parent9a3c9ba7beb18dfd6232deb895528ea8593a12b0 (diff)
downloadsqlalchemy-pr/264.tar.gz
Add window frame specificationpr/264
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 3d2f02006..33de2424b 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -812,12 +812,23 @@ class SQLCompiler(Compiled):
return "%s OVER (%s)" % (
over.element._compiler_dispatch(self, **kwargs),
' '.join(
- '%s BY %s' % (word, clause._compiler_dispatch(self, **kwargs))
- for word, clause in (
- ('PARTITION', over.partition_by),
- ('ORDER', over.order_by)
+ itertools.chain(
+ (
+ '%s BY %s' % (
+ word, clause._compiler_dispatch(self, **kwargs)
+ )
+ for word, clause in (
+ ('PARTITION', over.partition_by),
+ ('ORDER', over.order_by)
+ )
+ if clause is not None and len(clause)
+ ),
+ [
+ '%s BETWEEN %s AND %s' % (
+ over.frame_kind, over.preceding, over.following
+ )
+ ]
)
- if clause is not None and len(clause)
)
)