Author: phd
Date: 2008-02-28 07:19:53 -0700 (Thu, 28 Feb 2008)
New Revision: 3276
Modified:
SQLObject/branches/0.10/docs/News.txt
SQLObject/branches/0.10/sqlobject/main.py
SQLObject/branches/0.10/sqlobject/tests/test_basic.py
Log:
Fixed a bug with no default when defaultSQL is defined for the column.
Modified: SQLObject/branches/0.10/docs/News.txt
===================================================================
--- SQLObject/branches/0.10/docs/News.txt 2008-02-28 14:19:31 UTC (rev 3275)
+++ SQLObject/branches/0.10/docs/News.txt 2008-02-28 14:19:53 UTC (rev 3276)
@@ -80,6 +80,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.10/sqlobject/main.py
===================================================================
--- SQLObject/branches/0.10/sqlobject/main.py 2008-02-28 14:19:31 UTC (rev 3275)
+++ SQLObject/branches/0.10/sqlobject/main.py 2008-02-28 14:19:53 UTC (rev 3276)
@@ -1199,8 +1199,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.10/sqlobject/tests/test_basic.py
===================================================================
--- SQLObject/branches/0.10/sqlobject/tests/test_basic.py 2008-02-28 14:19:31 UTC (rev 3275)
+++ SQLObject/branches/0.10/sqlobject/tests/test_basic.py 2008-02-28 14:19:53 UTC (rev 3276)
@@ -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
|