diff options
author | Phillip Cloud <cpcloud@gmail.com> | 2016-05-01 17:56:35 -0700 |
---|---|---|
committer | Phillip Cloud <cpcloud@gmail.com> | 2016-05-01 17:56:35 -0700 |
commit | 77fe28546e7124205e50c769f203f8330e35bac7 (patch) | |
tree | 3f234d9def153f6358bdd3490081bb5112966e6b /lib/sqlalchemy/sql/compiler.py | |
parent | 9a3c9ba7beb18dfd6232deb895528ea8593a12b0 (diff) | |
download | sqlalchemy-pr/264.tar.gz |
Add window frame specificationpr/264
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 21 |
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) ) ) |