[SQL-CVS] r2367 - SQLObject/trunk/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2007-03-02 14:48:03
|
Author: phd Date: 2007-03-02 07:47:45 -0700 (Fri, 02 Mar 2007) New Revision: 2367 Modified: SQLObject/trunk/sqlobject/col.py SQLObject/trunk/sqlobject/main.py Log: Aplied the patch 1450584: Support for DEFAULT SQL attribute. Modified: SQLObject/trunk/sqlobject/col.py =================================================================== --- SQLObject/trunk/sqlobject/col.py 2007-03-02 14:43:22 UTC (rev 2366) +++ SQLObject/trunk/sqlobject/col.py 2007-03-02 14:47:45 UTC (rev 2367) @@ -112,6 +112,7 @@ creationOrder, dbName=None, default=NoDefault, + defaultSQL=None, foreignKey=None, alternateID=False, alternateMethodName=None, @@ -178,6 +179,7 @@ self.name = name self.soClass = soClass self._default = default + self.defaultSQL = defaultSQL self.customSQLType = sqlType # deal with foreign keys @@ -293,6 +295,8 @@ result.append('NOT NULL') if self.unique or self.alternateID: result.append('UNIQUE') + if self.defaultSQL is not None: + result.append("DEFAULT %s" % self.defaultSQL) return result def _sqlType(self): Modified: SQLObject/trunk/sqlobject/main.py =================================================================== --- SQLObject/trunk/sqlobject/main.py 2007-03-02 14:43:22 UTC (rev 2366) +++ SQLObject/trunk/sqlobject/main.py 2007-03-02 14:47:45 UTC (rev 2367) @@ -1231,7 +1231,8 @@ default = column.default # If we don't get it, it's an error: - if default is NoDefault: + # 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) # Otherwise we put it in as though they did pass # that keyword: |