Example #1
0
 def sybaseCreateSQL(self):
     sql = SOKeyCol.sybaseCreateSQL(self)
     other = findClass(self.foreignKey)
     tName = other.sqlmeta.table
     idName = other.sqlmeta.idName
     reference = "REFERENCES %(tName)s(%(idName)s) " % {"tName": tName, "idName": idName}
     sql = " ".join([sql, reference])
     return sql
Example #2
0
 def maxdbCreateSQL(self):
     other = findClass(self.foreignKey)
     fidName = self.dbName
     # I assume that foreign key name is identical to the id of the reference table
     sql = " ".join([fidName, self._maxdbType()])
     tName = other.sqlmeta.table
     idName = other.sqlmeta.idName
     sql = sql + "," + "\n"
     sql = sql + "FOREIGN KEY (%s) REFERENCES %s(%s)" % (fidName, tName, idName)
     return sql
Example #3
0
File: col.py Project: fregaham/DISP
 def mssqlCreateSQL(self):
     sql = SOKeyCol.mssqlCreateSQL(self)
     other = findClass(self.foreignKey)
     tName = other.sqlmeta.table
     idName = other.sqlmeta.idName
     reference = ('REFERENCES %(tName)s(%(idName)s) ' %
                  {'tName':tName,
                   'idName':idName})
     sql = ' '.join([sql, reference])
     return sql
Example #4
0
 def maxdbCreateSQL(self):
     other = findClass(self.foreignKey, self.soClass.sqlmeta.registry)
     fidName = self.dbName
     #I assume that foreign key name is identical to the id of the reference table
     sql = ' '.join([fidName, self._maxdbType()])
     tName = other.sqlmeta.table
     idName = other.sqlmeta.idName
     sql = sql + ',' + '\n'
     sql = sql + 'FOREIGN KEY (%s) REFERENCES %s(%s)' % (fidName, tName, idName)
     return sql
Example #5
0
 def mssqlCreateSQL(self, connection=None):
     sql = SOKeyCol.mssqlCreateSQL(self, connection)
     other = findClass(self.foreignKey, self.soClass.sqlmeta.registry)
     tName = other.sqlmeta.table
     idName = other.sqlmeta.idName
     reference = ('REFERENCES %(tName)s(%(idName)s) ' % 
                  {'tName':tName,
                   'idName':idName})
     sql = ' '.join([sql, reference])
     return sql
Example #6
0
 def postgresCreateSQL(self):
     sql = SOKeyCol.postgresCreateSQL(self)
     other = findClass(self.foreignKey, self.soClass.sqlmeta.registry)
     tName = other.sqlmeta.table
     idName = other.sqlmeta.idName
     if self.cascade is not None:
         if self.cascade == "null":
             action = "ON DELETE SET NULL"
         elif self.cascade:
             action = "ON DELETE CASCADE"
         else:
             action = "ON DELETE RESTRICT"
     else:
         action = ""
     constraint = (
         "CONSTRAINT %(colName)s_exists "
         "FOREIGN KEY (%(colName)s) "
         "REFERENCES %(tName)s (%(idName)s) "
         "%(action)s" % {"tName": tName, "colName": self.dbName, "idName": idName, "action": action}
     )
     sql = ", ".join([sql, constraint])
     return sql
Example #7
0
File: col.py Project: fregaham/DISP
 def mysqlCreateReferenceConstraint(self):
     sTName = self.soClass.sqlmeta.table
     other = findClass(self.foreignKey, self.soClass.sqlmeta.registry)
     tName = other.sqlmeta.table
     idName = other.sqlmeta.idName
     if self.cascade is not None:
         if self.cascade == 'null':
             action = 'ON DELETE SET NULL'
         elif self.cascade:
             action = 'ON DELETE CASCADE'
         else:
             action = 'ON DELETE RESTRICT'
     else:
         action = ''
     constraint = ('ALTER TABLE %(sTName)s ADD CONSTRAINT %(sTName)s_%(colName)s_exists '
                   'FOREIGN KEY (%(colName)s) '
                   'REFERENCES %(tName)s (%(idName)s) '
                   '%(action)s' %
                   {'tName': tName,
                    'colName': self.dbName,
                    'idName': idName,
                    'action': action,
                    'sTName': sTName})
     return constraint
Example #8
0
 def sqliteCreateSQL(self):
     sql = SOKeyCol.sqliteCreateSQL(self)
     other = findClass(self.foreignKey, self.soClass.sqlmeta.registry)
     tName = other.sqlmeta.table
     idName = other.sqlmeta.idName
     if self.cascade is not None:
         if self.cascade == 'null':
             action = 'ON DELETE SET NULL'
         elif self.cascade:
             action = 'ON DELETE CASCADE'
         else:
             action = 'ON DELETE RESTRICT'
     else:
         action = ''
     constraint = ('CONSTRAINT %(colName)s_exists '
                   #'FOREIGN KEY(%(colName)s) '
                   'REFERENCES %(tName)s(%(idName)s) '
                   '%(action)s' % 
                   {'tName': tName,
                    'colName': self.dbName,
                    'idName': idName,
                    'action': action})
     sql = ' '.join([sql, constraint])
     return sql