From: Mike Bayer Date: Thu, 13 May 2010 19:26:53 +0000 (-0400) Subject: - func.XXX() doesn't inadvertently resolve to non-Function X-Git-Tag: rel_0_6_1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a8f2207f0874c9639a2968e18bce88e6cb55c69;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - func.XXX() doesn't inadvertently resolve to non-Function classes (e.g. fixes func.text()). [ticket:1798] --- diff --git a/CHANGES b/CHANGES index 3438fab4f6..b49116a614 100644 --- 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] diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 9ac5c1d66d..5084495c32 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -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( diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py index 1784af37f2..c9bb8348c7 100644 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@ -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)