diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-29 17:33:28 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-29 17:33:28 -0500 |
commit | 8afb69ced876200c6bc4013108900e067130cb0e (patch) | |
tree | 0bdba7e4f5dee342a0d96497f404bf071f53e49d /lib/sqlalchemy/sql/functions.py | |
parent | 00e78f5f76c0f3e1000a7d239beed2d665170238 (diff) | |
download | sqlalchemy-8afb69ced876200c6bc4013108900e067130cb0e.tar.gz |
- Fixed regression whereby the "annotation" system used by the ORM was leaking
into the names used by standard functions in :mod:`sqlalchemy.sql.functions`,
such as ``func.coalesce()`` and ``func.max()``. Using these functions
in ORM attributes and thus producing annotated versions of them could
corrupt the actual function name rendered in the SQL. [ticket:2927]
Diffstat (limited to 'lib/sqlalchemy/sql/functions.py')
-rw-r--r-- | lib/sqlalchemy/sql/functions.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py index f300e2416..a9b88b13b 100644 --- a/lib/sqlalchemy/sql/functions.py +++ b/lib/sqlalchemy/sql/functions.py @@ -17,6 +17,7 @@ from .selectable import FromClause, Select from . import operators from .visitors import VisitableType from .. import util +from . import annotation _registry = util.defaultdict(dict) @@ -308,16 +309,16 @@ class Function(FunctionElement): _compared_to_type=self.type, unique=True) - class _GenericMeta(VisitableType): def __init__(cls, clsname, bases, clsdict): - cls.name = name = clsdict.get('name', clsname) - cls.identifier = identifier = clsdict.get('identifier', name) - package = clsdict.pop('package', '_default') - # legacy - if '__return_type__' in clsdict: - cls.type = clsdict['__return_type__'] - register_function(identifier, cls, package) + if annotation.Annotated not in cls.__mro__: + cls.name = name = clsdict.get('name', clsname) + cls.identifier = identifier = clsdict.get('identifier', name) + package = clsdict.pop('package', '_default') + # legacy + if '__return_type__' in clsdict: + cls.type = clsdict['__return_type__'] + register_function(identifier, cls, package) super(_GenericMeta, cls).__init__(clsname, bases, clsdict) @@ -407,7 +408,6 @@ class GenericFunction(util.with_metaclass(_GenericMeta, Function)): self.type = sqltypes.to_instance( kwargs.pop("type_", None) or getattr(self, 'type', None)) - register_function("cast", Cast) register_function("extract", Extract) |