summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlja Everilä <saarni@gmail.com>2014-09-11 15:29:33 +0300
committerIlja Everilä <saarni@gmail.com>2014-09-11 15:29:33 +0300
commitab1c25266dd49f087b5fff316b6ba6fb610b1d35 (patch)
tree667e0f42fd95c96281617c47684594173fb00aca
parenta3cd517c95e5f341c711c41474de14db97bb7778 (diff)
downloadsqlalchemy-ab1c25266dd49f087b5fff316b6ba6fb610b1d35.tar.gz
renamed aggregatefilter to funcfilter, since it is that
-rw-r--r--lib/sqlalchemy/__init__.py2
-rw-r--r--lib/sqlalchemy/sql/__init__.py2
-rw-r--r--lib/sqlalchemy/sql/compiler.py6
-rw-r--r--lib/sqlalchemy/sql/elements.py18
-rw-r--r--lib/sqlalchemy/sql/expression.py6
-rw-r--r--lib/sqlalchemy/sql/functions.py14
-rw-r--r--test/sql/test_compiler.py2
-rw-r--r--test/sql/test_generative.py2
8 files changed, 26 insertions, 26 deletions
diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py
index 1af0de3ba..d184e1fbf 100644
--- a/lib/sqlalchemy/__init__.py
+++ b/lib/sqlalchemy/__init__.py
@@ -7,7 +7,6 @@
from .sql import (
- aggregatefilter,
alias,
and_,
asc,
@@ -26,6 +25,7 @@ from .sql import (
extract,
false,
func,
+ funcfilter,
insert,
intersect,
intersect_all,
diff --git a/lib/sqlalchemy/sql/__init__.py b/lib/sqlalchemy/sql/__init__.py
index 8fbf1b536..351e08d0b 100644
--- a/lib/sqlalchemy/sql/__init__.py
+++ b/lib/sqlalchemy/sql/__init__.py
@@ -19,7 +19,6 @@ from .expression import (
Selectable,
TableClause,
Update,
- aggregatefilter,
alias,
and_,
asc,
@@ -39,6 +38,7 @@ from .expression import (
false,
False_,
func,
+ funcfilter,
insert,
intersect,
intersect_all,
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 6ebd61e9c..d59012d12 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -760,10 +760,10 @@ class SQLCompiler(Compiled):
)
)
- def visit_aggregatefilter(self, aggregatefilter, **kwargs):
+ def visit_funcfilter(self, funcfilter, **kwargs):
return "%s FILTER (WHERE %s)" % (
- aggregatefilter.func._compiler_dispatch(self, **kwargs),
- aggregatefilter.criterion._compiler_dispatch(self, **kwargs)
+ funcfilter.func._compiler_dispatch(self, **kwargs),
+ funcfilter.criterion._compiler_dispatch(self, **kwargs)
)
def visit_extract(self, extract, **kwargs):
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index 5562e80d7..5ac16ab7a 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -2888,28 +2888,28 @@ class Over(ColumnElement):
))
-class AggregateFilter(ColumnElement):
- """Represent an aggregate FILTER clause.
+class FunctionFilter(ColumnElement):
+ """Represent a function FILTER clause.
- This is a special operator against aggregate functions,
+ This is a special operator against aggregate and window functions,
which controls which rows are passed to it.
It's supported only by certain database backends.
"""
- __visit_name__ = 'aggregatefilter'
+ __visit_name__ = 'funcfilter'
criterion = None
def __init__(self, func, *criterion):
- """Produce an :class:`.AggregateFilter` object against a function.
+ """Produce an :class:`.FunctionFilter` object against a function.
- Used against aggregate functions,
- for database backends that support aggregate "FILTER" clause.
+ Used against aggregate and window functions,
+ for database backends that support the "FILTER" clause.
E.g.::
- from sqlalchemy import aggregatefilter
- aggregatefilter(func.count(1), MyClass.name == 'some name')
+ from sqlalchemy import funcfilter
+ funcfilter(func.count(1), MyClass.name == 'some name')
Would produce "COUNT(1) FILTER (WHERE myclass.name = 'some name')".
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 7b22cab3e..2e10b7370 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -36,7 +36,7 @@ from .elements import ClauseElement, ColumnElement,\
True_, False_, BinaryExpression, Tuple, TypeClause, Extract, \
Grouping, not_, \
collate, literal_column, between,\
- literal, outparam, type_coerce, ClauseList, AggregateFilter
+ literal, outparam, type_coerce, ClauseList, FunctionFilter
from .elements import SavepointClause, RollbackToSavepointClause, \
ReleaseSavepointClause
@@ -97,8 +97,8 @@ outerjoin = public_factory(Join._create_outerjoin, ".expression.outerjoin")
insert = public_factory(Insert, ".expression.insert")
update = public_factory(Update, ".expression.update")
delete = public_factory(Delete, ".expression.delete")
-aggregatefilter = public_factory(
- AggregateFilter, ".expression.aggregatefilter")
+funcfilter = public_factory(
+ FunctionFilter, ".expression.funcfilter")
# internal functions still being called from tests and the ORM,
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py
index 46f3e27dc..a07eca8c6 100644
--- a/lib/sqlalchemy/sql/functions.py
+++ b/lib/sqlalchemy/sql/functions.py
@@ -12,7 +12,7 @@ from . import sqltypes, schema
from .base import Executable, ColumnCollection
from .elements import ClauseList, Cast, Extract, _literal_as_binds, \
literal_column, _type_from_args, ColumnElement, _clone,\
- Over, BindParameter, AggregateFilter
+ Over, BindParameter, FunctionFilter
from .selectable import FromClause, Select, Alias
from . import operators
@@ -119,8 +119,8 @@ class FunctionElement(Executable, ColumnElement, FromClause):
def filter(self, *criterion):
"""Produce a FILTER clause against this function.
- Used against aggregate functions,
- for database backends that support aggregate "FILTER" clause.
+ Used against aggregate and window functions,
+ for database backends that support the "FILTER" clause.
The expression::
@@ -128,15 +128,15 @@ class FunctionElement(Executable, ColumnElement, FromClause):
is shorthand for::
- from sqlalchemy import aggregatefilter
- aggregatefilter(func.count(1), True)
+ from sqlalchemy import funcfilter
+ funcfilter(func.count(1), True)
- See :func:`~.expression.aggregatefilter` for a full description.
+ See :func:`~.expression.funcfilter` for a full description.
"""
if not criterion:
return self
- return AggregateFilter(self, *criterion)
+ return FunctionFilter(self, *criterion)
@property
def _from_objects(self):
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py
index 6e730ad50..7bba29563 100644
--- a/test/sql/test_compiler.py
+++ b/test/sql/test_compiler.py
@@ -2190,7 +2190,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
"(ORDER BY mytable.myid + :myid_1) AS anon_1 FROM mytable"
)
- def test_aggregate_filter(self):
+ def test_funcfilter(self):
self.assert_compile(
func.count(1).filter(),
"count(:param_1)"
diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py
index 1b67ab68c..6044cecb0 100644
--- a/test/sql/test_generative.py
+++ b/test/sql/test_generative.py
@@ -539,7 +539,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL):
expr2 = CloningVisitor().traverse(expr)
assert str(expr) == str(expr2)
- def test_aggregatefilter(self):
+ def test_funcfilter(self):
expr = func.count(1).filter(t1.c.col1 > 1)
expr2 = CloningVisitor().traverse(expr)
assert str(expr) == str(expr2)