From: Mike Bayer Date: Wed, 28 Mar 2007 23:18:04 +0000 (+0000) Subject: - sending None as an argument to func. will produce X-Git-Tag: rel_0_3_7~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c13846c6b66411e8b11af0948def34691637435b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - sending None as an argument to func. will produce an argument of NULL --- diff --git a/CHANGES b/CHANGES index dfb5f08eeb..2289a14b27 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,8 @@ - preliminary support for unicode table and column names added. - fix for fetchmany() "size" argument being positional in most dbapis [ticket:505] + - sending None as an argument to func. will produce + an argument of NULL - orm: - improved/fixed custom collection classes when giving it "set"/ "sets.Set" classes or subclasses (was still looking for append() diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 78d07bec85..9bdbc0cb8c 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -1565,7 +1565,7 @@ class _Function(_CalculatedClause, FromClause): self.type = sqltypes.to_instance(kwargs.get('type', None)) self.packagenames = kwargs.get('packagenames', None) or [] self._engine = kwargs.get('engine', None) - ClauseList.__init__(self, parens=True, *clauses) + ClauseList.__init__(self, parens=True, *[c is None and _Null() or c for c in clauses]) key = property(lambda self:self.name) diff --git a/test/sql/select.py b/test/sql/select.py index f71d5366b2..7406d6c4fe 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -466,7 +466,10 @@ FROM mytable, myothertable WHERE foo.id = foofoo(lala) AND datetime(foo) = Today # test a dotted func off the engine itself self.runtest(func.lala.hoho(7), "lala.hoho(:hoho)") - + + # test None becomes NULL + self.runtest(func.my_func(1,2,None,3), "my_func(:my_func, :my_func_1, NULL, :my_func_2)") + def testextract(self): """test the EXTRACT function""" self.runtest(select([extract("month", table3.c.otherstuff)]), "SELECT extract(month FROM thirdtable.otherstuff) FROM thirdtable")