[SQLObject] SQLObject 0.6 fixes for Firebird
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian S. <Ian...@et...> - 2004-05-25 14:23:02
|
I've been trying to use Firebird with the SVN version of SQLObject. As a = result I have a couple of fixes to submit. All can easily be added to = col.py : Line 476: (class SOEnumCol) : def _firebirdType(self): """For enum columns firebird needs <typedef> <extraSQL> CHECK... but extraSQL isn't going to get added until firebirdCreateSQL = so we=20 return a tuple of <typedef>,<check> so that CreateSQL can = insert its extraSQL between them. """ length =3D max(map(len, self.enumValues)) enumValues =3D ', '.join([sqlbuilder.sqlrepr(v, 'firebird') for = v in self.enumValues]) checkConstraint =3D "CHECK (%s in (%s))" % (self.dbName, = enumValues) #NB. Return a tuple, not a string here return "VARCHAR(%i)" % (length), checkConstraint Line 218 : def firebirdCreateSQL(self): # Ian Sparks pointed out that fb is picky about the order # of the NOT NULL clause in a create statement. So, we handle # them differently for Enum columns. if not isinstance(self, SOEnumCol): return ' '.join([self.dbName, self._firebirdType()] + = self._extraSQL()) else: ##firebird SoEnumColumn returns a tuple return ' '.join([self.dbName] + [self._firebirdType()[0]] + = self._extraSQL() + [self._firebirdType()[1]]) Line 505 (class SODateTimeCol) : def _firebirdType(self): return 'TIMESTAMP' Line 527 (class SODateCol) : def _firebirdType(self): return 'DATE' All the firebird tests (that passed before) still pass. A note about the = tests : Some of them use python 2.3 specific code like sum(). Maybe = SQLObject now requires Python 2.3+ ? |