summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/functions.py
diff options
context:
space:
mode:
authorAdrien Berchet <adrien.berchet@gmail.com>2019-05-03 12:02:17 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-05-06 17:41:34 -0400
commit61c47cbdc6058c040b301caa0864710a8d85d3a4 (patch)
tree109d512de7613f2f8496e285b39426b485321d2b /lib/sqlalchemy/sql/functions.py
parent1c3e92627362604472ca483055fc827a97942e6b (diff)
downloadsqlalchemy-61c47cbdc6058c040b301caa0864710a8d85d3a4.tar.gz
Do not register the GenericFunction in sql.functions._registry
Fixed that the :class:`.GenericFunction` class was inadvertently registering itself as one of the named functions. Pull request courtesy Adrien Berchet. Fixes: #4653 Closes: #4654 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4654 Pull-request-sha: 1112b89f0d5af8cd5ba88cef744698a79dbdb963 Change-Id: Ia0d366d3bff44a763aa496287814278dff732a19
Diffstat (limited to 'lib/sqlalchemy/sql/functions.py')
-rw-r--r--lib/sqlalchemy/sql/functions.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py
index feb4fdb90..d0aa23988 100644
--- a/lib/sqlalchemy/sql/functions.py
+++ b/lib/sqlalchemy/sql/functions.py
@@ -603,7 +603,17 @@ class _GenericMeta(VisitableType):
# legacy
if "__return_type__" in clsdict:
cls.type = clsdict["__return_type__"]
- register_function(identifier, cls, package)
+
+ # Check _register attribute status
+ cls._register = getattr(cls, '_register', True)
+
+ # Register the function if required
+ if cls._register:
+ register_function(identifier, cls, package)
+ else:
+ # Set _register to True to register child classes by default
+ cls._register = True
+
super(_GenericMeta, cls).__init__(clsname, bases, clsdict)
@@ -671,6 +681,7 @@ class GenericFunction(util.with_metaclass(_GenericMeta, Function)):
"""
coerce_arguments = True
+ _register = False
def __init__(self, *args, **kwargs):
parsed_args = kwargs.pop("_parsed_args", None)