]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- func.XXX() doesn't inadvertently resolve to non-Function
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 13 May 2010 19:26:53 +0000 (15:26 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 13 May 2010 19:26:53 +0000 (15:26 -0400)
classes (e.g. fixes func.text()).  [ticket:1798]

CHANGES
lib/sqlalchemy/sql/expression.py
test/sql/test_functions.py

diff --git a/CHANGES b/CHANGES
index 3438fab4f6f26e9f65ee970d63c6c5a84626fcd5..b49116a614b5f328ba6f1f4bef6dcb9914d8224b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -38,6 +38,9 @@ CHANGES
     easier to produce specific subclasses of these which work in 
     alias/subquery situations.
 
+  - func.XXX() doesn't inadvertently resolve to non-Function 
+    classes (e.g. fixes func.text()).  [ticket:1798]
+
 - engines
   - Fixed building the C extensions on Python 2.4. [ticket:1781]
 
index 9ac5c1d66d9f04fe1be081e8f9181519e5618798..5084495c32c5f3c57c94f060098f06f13b0b658c 100644 (file)
@@ -855,7 +855,9 @@ class _FunctionGenerator(object):
             if functions is None:
                 from sqlalchemy.sql import functions
             func = getattr(functions, self.__names[-1].lower(), None)
-            if func is not None:
+            if func is not None and \
+                    isinstance(func, type) and \
+                    issubclass(func, Function):
                 return func(*c, **o)
 
         return Function(
index 1784af37f2deb47a8755bed687fe4423d822277e..c9bb8348c7189030fbfd463bbbee1f2c2297d737 100644 (file)
@@ -69,7 +69,10 @@ class CompileTest(TestBase, AssertsCompiledSQL):
             ('random', oracle.dialect())
         ]:
             self.assert_compile(func.random(), ret, dialect=dialect)
-
+    
+    def test_namespacing_conflicts(self):
+        self.assert_compile(func.text('foo'), 'text(:text_1)')
+        
     def test_generic_count(self):
         assert isinstance(func.count().type, sqltypes.Integer)