[SQL-CVS] r3275 - in SQLObject/branches/0.9: docs sqlobject sqlobject/tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2008-02-28 14:19:38
|
Author: phd Date: 2008-02-28 07:19:31 -0700 (Thu, 28 Feb 2008) New Revision: 3275 Modified: SQLObject/branches/0.9/docs/News.txt SQLObject/branches/0.9/sqlobject/main.py SQLObject/branches/0.9/sqlobject/tests/test_basic.py Log: Fixed a bug with no default when defaultSQL is defined for the column. Modified: SQLObject/branches/0.9/docs/News.txt =================================================================== --- SQLObject/branches/0.9/docs/News.txt 2008-02-28 10:53:58 UTC (rev 3274) +++ SQLObject/branches/0.9/docs/News.txt 2008-02-28 14:19:31 UTC (rev 3275) @@ -15,6 +15,8 @@ * Prevent MultipleJoin from removing the intermediate table if it was not created by the Join. +* Fixed a bug with no default when defaultSQL is defined for the column. + SQLObject 0.9.3 =============== Modified: SQLObject/branches/0.9/sqlobject/main.py =================================================================== --- SQLObject/branches/0.9/sqlobject/main.py 2008-02-28 10:53:58 UTC (rev 3274) +++ SQLObject/branches/0.9/sqlobject/main.py 2008-02-28 14:19:31 UTC (rev 3275) @@ -1228,8 +1228,14 @@ # If we don't get it, it's an error: # If we specified an SQL DEFAULT, then we should use that - if default is NoDefault and column.defaultSQL is not None: - raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, column.name) + if default is NoDefault: + if column.defaultSQL is None: + raise TypeError, "%s() did not get expected keyword argument '%s'" % (self.__class__.__name__, column.name) + else: + # There is defaultSQL for the column - do not put + # the column to kw so that the backend creates the value + continue + # Otherwise we put it in as though they did pass # that keyword: Modified: SQLObject/branches/0.9/sqlobject/tests/test_basic.py =================================================================== --- SQLObject/branches/0.9/sqlobject/tests/test_basic.py 2008-02-28 10:53:58 UTC (rev 3274) +++ SQLObject/branches/0.9/sqlobject/tests/test_basic.py 2008-02-28 14:19:31 UTC (rev 3275) @@ -302,3 +302,12 @@ def test_sqlmeta_inherited_idName(): setupClass(TestSO12) assert TestSO12.sqlmeta.idName == "my_id" + +class TestSO13(SQLObject): + name = StringCol() + value = IntCol(defaultSQL='1') + +def test_defaultSQL(): + setupClass(TestSO13) + test = TestSO13(name="test") + assert test.value == 1 |