commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r6511 - trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creat


From: btami
Subject: r6511 - trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creation
Date: Tue, 19 Oct 2004 06:26:39 -0500 (CDT)

Author: btami
Date: 2004-10-19 06:26:37 -0500 (Tue, 19 Oct 2004)
New Revision: 6511

Modified:
   
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creation/Creation.py
Log:
fixed default handling of defaulthwith="serial"

Modified: 
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creation/Creation.py
===================================================================
--- 
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creation/Creation.py 
    2004-10-19 08:54:11 UTC (rev 6510)
+++ 
trunk/gnue-common/src/datasources/drivers/interbase/Schema/Creation/Creation.py 
    2004-10-19 11:26:37 UTC (rev 6511)
@@ -95,15 +95,20 @@
     if fieldDef ['defaultwith'] == 'serial':
       seq = self._getSequenceName (tableName, fieldDef)
       code [0].append (u"CREATE GENERATOR %s%s" % (seq, self.END_COMMAND))
-      fieldDef ['default'] = "nextval ('%s')" % seq
       fName = fieldDef ['name']
 
-      code [2].append (u"SET TERM ^ ;")
+# TODO: this code works with options -f -o only
+#      code [2].append (u"SET TERM ^ ;")
+#      code [2].append (u"CREATE TRIGGER trg_%s FOR %s ACTIVE "
+#          "BEFORE INSERT POSITION 0 AS BEGIN "
+#          "IF (NEW.%s IS NULL) THEN NEW.%s = GEN_ID (%s,1); "
+#          "END ^" % (fName, tableName, fName, fName, seq))
+#      code [2].append (u"SET TERM ; ^")
+
       code [2].append (u"CREATE TRIGGER trg_%s FOR %s ACTIVE "
-          "BEFORE INSERT POSITION 0 AS BEGIN "
-          "IF (NEW.%s IS NULL) THEN BEGIN NEW.%s = GEN_ID (%s,1); END"
-          "END ^" % (fName, tableName, fName, fName, seq))
-      code [2].append (u"SET TERM ; ^")
+          "BEFORE INSERT POSITION 0 AS "
+          "BEGIN IF (NEW.%s IS NULL) THEN NEW.%s = GEN_ID (%s,1); END"
+           % (fName, tableName, fName, fName, seq))
 
     elif fieldDef ['defaultwith'] == 'timestamp':
       fieldDef ['default'] = "'NOW'"





reply via email to

[Prev in Thread] Current Thread [Next in Thread]