2 ms·
Does this trick work with foreign keys? Like, if you have an ON CASCADE DELETE, does it delete a bunch of rows in other tables when converting the table to stri
by OskarS 3mo ago
Does this trick work with foreign keys? Like, if you have an ON CASCADE DELETE, does it delete a bunch of rows in other tables when converting the table to strict?
- simonw 3mo agoIt uses "PRAGMA foreign_keys=0" and "PRAGMA defer_foreign_keys= ON" before running the transformation, then resets those settings afterwards: https://github.com/simonw/sqlite-utils/blob/3f0471701b5f8c7de888a467020e5dd34310ce9a/sqlite_utils/db.py#L2571 https://github.com/simonw/sqlite-utils/blob/3f0471701b5f8c7d... That's the pattern recommended by SQLite here: https://www.sqlite.org/lang_altertable.html#otheralter https://www.sqlite.org/lang_altertable.html#otheralter
- simonw 3mo agoThanks for the nudge, I just added a new test explicitly covering this: https://github.com/simonw/sqlite-utils/commit/d71420065903ff54247b5062b8c6af6165b7e638 https://github.com/simonw/sqlite-utils/commit/d71420065903ff...