summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/functions.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql/functions.py')
-rw-r--r--lib/sqlalchemy/sql/functions.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py
index f48a20ec7..0e92d5e50 100644
--- a/lib/sqlalchemy/sql/functions.py
+++ b/lib/sqlalchemy/sql/functions.py
@@ -256,6 +256,9 @@ class FunctionElement(Executable, ColumnElement, FromClause):
def get_children(self, **kwargs):
return (self.clause_expr,)
+ def _cache_key(self, **kw):
+ return (FunctionElement, self.clause_expr._cache_key(**kw))
+
def _copy_internals(self, clone=_clone, **kw):
self.clause_expr = clone(self.clause_expr, **kw)
self._reset_exported()
@@ -406,6 +409,14 @@ class FunctionAsBinary(BinaryExpression):
def get_children(self, **kw):
yield self.sql_function
+ def _cache_key(self, **kw):
+ return (
+ FunctionAsBinary,
+ self.sql_function._cache_key(**kw),
+ self.left_index,
+ self.right_index,
+ )
+
class _FunctionGenerator(object):
"""Generate :class:`.Function` objects based on getattr calls."""
@@ -566,6 +577,13 @@ class Function(FunctionElement):
unique=True,
)
+ def _cache_key(self, **kw):
+ return (
+ (Function,) + tuple(self.packagenames)
+ if self.packagenames
+ else () + (self.name, self.clause_expr._cache_key(**kw))
+ )
+
class _GenericMeta(VisitableType):
def __init__(cls, clsname, bases, clsdict):
@@ -684,6 +702,9 @@ class next_value(GenericFunction):
self._bind = kw.get("bind", None)
self.sequence = seq
+ def _cache_key(self, **kw):
+ return (next_value, self.sequence.name)
+
def compare(self, other, **kw):
return (
isinstance(other, next_value)