Commit db677c4
committed
Fix MySQL test cleanup by using DELETE instead of TRUNCATE
The original approach of disabling foreign key checks before TRUNCATE
was unreliable due to MySQL's session-based FOREIGN_KEY_CHECKS setting
and Sequel's connection pooling. Each db.run() call can get a different
connection from the pool, so SET FOREIGN_KEY_CHECKS=0 executed on one
connection doesn't affect TRUNCATE statements executed on other connections.
Solution: Use DELETE FROM instead of TRUNCATE for MySQL test cleanup.
While slower, DELETE respects foreign key constraints by deleting in
the correct order, and doesn't require disabling FK checks.
PostgreSQL continues to use TRUNCATE with CASCADE, which handles
foreign keys correctly in a single statement.
This fixes the 208 test failures seen in CI with MySQL 8.2.1 parent c27eaf2 commit db677c4
1 file changed
+11
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
0 commit comments