[Zope-CVS] CVS: Products/Ape/lib/apelib/sql - dbapi.py:1.11

Shane Hathaway shane at zope.com
Thu Apr 15 19:15:43 EDT 2004


Update of /cvs-repository/Products/Ape/lib/apelib/sql
In directory cvs.zope.org:/tmp/cvs-serv23453

Modified Files:
	dbapi.py 
Log Message:
Patch by Elena Schulz: MySQL requires explicit NOT NULL constraint on primary keys.


=== Products/Ape/lib/apelib/sql/dbapi.py 1.10 => 1.11 ===
--- Products/Ape/lib/apelib/sql/dbapi.py:1.10	Thu Mar 25 22:31:52 2004
+++ Products/Ape/lib/apelib/sql/dbapi.py	Thu Apr 15 19:15:42 2004
@@ -226,9 +226,11 @@
         for name, typ, unique in column_defs:
             col = self.translate_name(name)
             db_type = self.translate_type(typ)
-            cols.append("%s %s" % (col, db_type))
+            constraints = ''
             if unique:
+                constraints = ' NOT NULL'
                 pkeys.append(col)
+            cols.append("%s %s%s" % (col, db_type, constraints))
         if pkeys:
             cols.append('PRIMARY KEY (%s)' % ', '.join(pkeys))
         sql = "CREATE TABLE %s (%s)" % (table_name, ', '.join(cols))




More information about the Zope-CVS mailing list