Commit 8345b14
CloudLobster
fix: PRAGMA defer_foreign_keys must run BEFORE batch transaction
SQLite rule: PRAGMA foreign_keys/defer_foreign_keys cannot be
changed inside a transaction. D1 batch() is an implicit transaction.
Previous fix put PRAGMA inside the batch where it had no effect.
Now runs PRAGMA defer_foreign_keys = ON as a separate .run()
call before the batch, which correctly defers FK checks for
the duration of the batch transaction.1 parent c980671 commit 8345b14
2 files changed
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
305 | 308 | | |
306 | | - | |
307 | 309 | | |
308 | 310 | | |
309 | 311 | | |
| |||
348 | 350 | | |
349 | 351 | | |
350 | 352 | | |
351 | | - | |
352 | 353 | | |
353 | | - | |
| 354 | + | |
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
189 | 191 | | |
190 | | - | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
227 | | - | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| |||
0 commit comments