Changeset 4418
- Timestamp:
- 04/03/09 21:27:01 (4 years ago)
- Location:
- branch/merger
- Files:
-
- 2 modified
-
sqlitedb.py (modified) (4 diffs)
-
tests/test_sqlite_column_merge.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/merger/sqlitedb.py
r4409 r4418 19 19 self.row_factory = _dict_factory 20 20 21 # XXX Missing: 22 # Index and trigger merging (read copying) 23 # Proper foreign key merging 21 24 22 25 def merge(new_dbpath, old_dbpath, dry_run=False): … … 77 80 return 78 81 82 res = new_cursor.execute("pragma foreign_key_list(%s)" % name) 83 reference = {} 84 for ref in res.fetchall(): 85 reference[ref['from']] = (ref['table'], ref['to']) 86 79 87 res = old_cursor.execute("pragma table_info(%s)" % name) 80 88 old_table_info = res.fetchall() … … 102 110 103 111 # Attempt to create new columns 104 # XXX not checking if they reference other columns yet.105 112 for cname, cinfo in new_by_col.iteritems(): 106 113 if cinfo['pk']: … … 117 124 if cinfo['dflt_value']: 118 125 query += " DEFAULT %s" % cinfo['dflt_value'] 126 if cname in reference: 127 query += " REFERENCES %s(%s)" % reference[cname] 119 128 old_cursor.execute(query) 120 129 -
branch/merger/tests/test_sqlite_column_merge.py
r4411 r4418 56 56 conn, cursor = conn_cursor(self.old_db_file.name) 57 57 # I don't care if the pragma table_info still exists or not, if it 58 # doesn't then let the test fail.58 # doesn't then the two next tests will be comparing empty lists. 59 59 old_table_info = cursor.execute( 60 60 "pragma table_info(%s)" % table).fetchall() … … 86 86 "b INTEGER") 87 87 88 # XXX not supported yet88 # XXX not fully supported yet 89 89 self._verify_merge( 90 "b INTEGER, c INTEGER CONSTRAINT fk REFERENCES d(id)", 91 "b INTEGER") 90 "a INTEGER, b INTEGER CONSTRAINT fk REFERENCES d(id)", 91 "a INTEGER") 92 self._verify_merge( 93 "a INTEGER, b INTEGER REFERENCES d(id) ON DELETE CASCADE", 94 "a INTEGER") 92 95 93 96 self._verify_merge_fails(sqlite.OperationalError,
