summaryrefslogtreecommitdiff
path: root/test/sql/test_functions.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-04-29 17:31:12 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-04-30 14:01:52 -0400
commitae14861a3197513db5f5a4e3991243482053a46c (patch)
tree9d6544fe694e3ffe2304013d43f9b17c6a1b99ea /test/sql/test_functions.py
parenta10a4ea1248902349d789de7f5470bb8e437a584 (diff)
downloadsqlalchemy-ae14861a3197513db5f5a4e3991243482053a46c.tar.gz
Make the GenericFunction registry fully case insensitive
Registered function names based on :class:`.GenericFunction` are now retrieved in a case-insensitive fashion in all cases, removing the deprecation logic from 1.3 which temporarily allowed multiple :class:`.GenericFunction` objects to exist with differing cases. A :class:`.GenericFunction` that replaces another on the same name whether or not it's case sensitive emits a warning before replacing the object. Fixes: #4649 Change-Id: I265ae19833132db07ed5b5ae40c4d24f659b1ab3
Diffstat (limited to 'test/sql/test_functions.py')
-rw-r--r--test/sql/test_functions.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py
index b03b156bc..ac711c669 100644
--- a/test/sql/test_functions.py
+++ b/test/sql/test_functions.py
@@ -57,12 +57,9 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
def setup(self):
self._registry = deepcopy(functions._registry)
- self._case_sensitive_registry = deepcopy(
- functions._case_sensitive_registry)
def teardown(self):
functions._registry = self._registry
- functions._case_sensitive_registry = self._case_sensitive_registry
def test_compile(self):
for dialect in all_dialects(exclude=("sybase",)):
@@ -96,7 +93,6 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
)
functions._registry['_default'].pop('fake_func')
- functions._case_sensitive_registry['_default'].pop('fake_func')
def test_use_labels(self):
self.assert_compile(
@@ -261,6 +257,28 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
assert isinstance(func.RePlAcEaBlE_fUnC().type, DateTime)
assert isinstance(func.replaceable_func().type, DateTime)
+ def test_replace_function_case_insensitive(self):
+ class replaceable_func(GenericFunction):
+ type = Integer
+ identifier = 'replaceable_func'
+
+ assert isinstance(func.Replaceable_Func().type, Integer)
+ assert isinstance(func.RePlAcEaBlE_fUnC().type, Integer)
+ assert isinstance(func.replaceable_func().type, Integer)
+
+ with expect_warnings(
+ "The GenericFunction 'replaceable_func' is already registered and "
+ "is going to be overriden.",
+ regex=False
+ ):
+ class replaceable_func_override(GenericFunction):
+ type = DateTime
+ identifier = 'REPLACEABLE_Func'
+
+ assert isinstance(func.Replaceable_Func().type, DateTime)
+ assert isinstance(func.RePlAcEaBlE_fUnC().type, DateTime)
+ assert isinstance(func.replaceable_func().type, DateTime)
+
def test_custom_w_custom_name(self):
class myfunc(GenericFunction):
name = "notmyfunc"