- sqlite
- [bug] the "name" of an FK constraint in SQLite
- is reflected as "None", not "0" [ticket:2364].
+ is reflected as "None", not "0" or other
+ integer value [ticket:2364].
SQLite does not appear to support constraint
- naming in any case (the names are ignored).
+ naming in any case.
- Py3K
- [bug] Fixed inappropriate usage of util.py3k
row = c.fetchone()
if row is None:
break
- (constraint_name, rtbl, lcol, rcol) = (row[0], row[2], row[3], row[4])
- if not constraint_name:
- constraint_name = None
+ (numerical_id, rtbl, lcol, rcol) = (row[0], row[2], row[3], row[4])
# sqlite won't return rcol if the table
# was created with REFERENCES <tablename>, no col
if rcol is None:
lcol = re.sub(r'^\"|\"$', '', lcol)
rcol = re.sub(r'^\"|\"$', '', rcol)
try:
- fk = fks[constraint_name]
+ fk = fks[numerical_id]
except KeyError:
fk = {
- 'name' : constraint_name,
+ 'name' : None,
'constrained_columns' : [],
'referred_schema' : None,
'referred_table' : rtbl,
'referred_columns' : []
}
fkeys.append(fk)
- fks[constraint_name] = fk
+ fks[numerical_id] = fk
# look up the table based on the given table's engine, not 'self',
# since it could be a ProxyEngine
__only_on__ = 'sqlite'
def setup(self):
- testing.db.execute("CREATE TABLE a (id INTEGER PRIMARY KEY)")
+ testing.db.execute("CREATE TABLE a1 (id INTEGER PRIMARY KEY)")
+ testing.db.execute("CREATE TABLE a2 (id INTEGER PRIMARY KEY)")
testing.db.execute("CREATE TABLE b (id INTEGER PRIMARY KEY, "
- "FOREIGN KEY(id) REFERENCES a(id))")
+ "FOREIGN KEY(id) REFERENCES a1(id),"
+ "FOREIGN KEY(id) REFERENCES a2(id)"
+ ")")
testing.db.execute("CREATE TABLE c (id INTEGER, "
"CONSTRAINT bar PRIMARY KEY(id),"
- "CONSTRAINT foo FOREIGN KEY(id) REFERENCES a(id))")
+ "CONSTRAINT foo1 FOREIGN KEY(id) REFERENCES a1(id),"
+ "CONSTRAINT foo2 FOREIGN KEY(id) REFERENCES a2(id)"
+ ")")
def teardown(self):
testing.db.execute("drop table c")
testing.db.execute("drop table b")
- testing.db.execute("drop table a")
+ testing.db.execute("drop table a1")
+ testing.db.execute("drop table a2")
def test_name_is_none(self):
# and not "0"
b = Table('b', meta, autoload=True, autoload_with=testing.db)
eq_(
[con.name for con in b.constraints],
- [None, None]
+ [None, None, None]
)
def test_name_not_none(self):