]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- changed char_length() to use a fake, neutral "generic function"
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 19 May 2008 22:46:14 +0000 (22:46 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 19 May 2008 22:46:14 +0000 (22:46 +0000)
- assert_compile() reports the dialect in use

test/sql/functions.py
test/testlib/testing.py

index 82814ef1b9c157d7df025ddc48680572a24c87cb..6754d6d42836ac49eafeebe14145402a446c4a25 100644 (file)
@@ -7,6 +7,7 @@ from sqlalchemy.sql.compiler import BIND_TEMPLATES
 from sqlalchemy.engine import default
 from sqlalchemy import types as sqltypes
 from testlib import *
+from sqlalchemy.sql.functions import GenericFunction
 
 from sqlalchemy.databases import *
 # every dialect in databases.__all__ is expected to pass these tests.
@@ -31,7 +32,15 @@ class CompileTest(TestBase, AssertsCompiledSQL):
                 self.assert_compile(func.nosuchfunction(), "nosuchfunction", dialect=dialect)
             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)
+            
+            # test generic function compile    
+            class fake_func(GenericFunction):
+                __return_type__ = sqltypes.Integer
+
+                def __init__(self, arg, **kwargs):
+                    GenericFunction.__init__(self, args=[arg], **kwargs)
+                
+            self.assert_compile(fake_func('foo'), "fake_func(%s)" % bindtemplate % {'name':'param_1', 'position':1}, dialect=dialect)
     
     def test_underscores(self):
         self.assert_compile(func.if_(), "if()")
index 28cc0388c99f0d856ffc5120b30be08d053c1bff..eda83a55df1ddd66f581bbd3b7ae9674180950f1 100644 (file)
@@ -695,7 +695,7 @@ class AssertsCompiledSQL(object):
 
         cc = re.sub(r'\n', '', str(c))
 
-        self.assertEquals(cc, result)
+        self.assertEquals(cc, result, "%r != %r on dialect %r" % (cc, result, dialect))
 
         if checkparams is not None:
             self.assertEquals(c.construct_params(params), checkparams)