From fc2cf22038e575670ee2edc890f8dfbc07d9bfa7 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 25 Mar 2008 17:25:20 +0000 Subject: [PATCH] - fixed SQL function truncation of trailing underscores [ticket:996] --- CHANGES | 5 ++++- lib/sqlalchemy/sql/expression.py | 2 +- test/sql/functions.py | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 5481768a6e..f9c2c5a7bd 100644 --- a/CHANGES +++ b/CHANGES @@ -20,7 +20,10 @@ CHANGES - Fixed bug which was preventing synonym() attributes from being used with inheritance - + + - fixed SQL function truncation of trailing underscores + [ticket:996] + - Session.execute can now find binds from metadata - adjusted the definition of "self-referential" to be diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 0d10c844ae..a3a25f5735 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -777,7 +777,7 @@ class _FunctionGenerator(object): except KeyError: raise AttributeError(name) - elif name.startswith('_'): + elif name.endswith('_'): name = name[0:-1] f = _FunctionGenerator(**self.opts) f.__names = list(self.__names) + [name] diff --git a/test/sql/functions.py b/test/sql/functions.py index e5c59b091c..d1ce17c72f 100644 --- a/test/sql/functions.py +++ b/test/sql/functions.py @@ -32,7 +32,10 @@ class CompileTest(TestBase, AssertsCompiledSQL): else: self.assert_compile(func.nosuchfunction(), "nosuchfunction()", dialect=dialect) self.assert_compile(func.char_length('foo'), "char_length(%s)" % bindtemplate % {'name':'param_1', 'position':1}, dialect=dialect) - + + def test_underscores(self): + self.assert_compile(func.if_(), "if()") + def test_generic_now(self): assert isinstance(func.now().type, sqltypes.DateTime) -- 2.47.3