Skip to content

Commit c02d5e5

Browse files
committed
Swallow 'sqlite_sequence may not be modified' (Turso restriction)
1 parent dc21d2f commit c02d5e5

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

.github/workflows/phpunit-tests-turso.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,36 @@ jobs:
560560
open(path, 'w').write(src)
561561
print('patched Turso error-message normalisation')
562562
563-
# 4. wp_die polyfill: real WordPress provides wp_die(); the unit-test
563+
# 4. Turso forbids writes to sqlite_sequence with "may not be modified".
564+
# The driver tries to DELETE from it when truncating a table; extend
565+
# the existing "no such table" swallow to also accept this error.
566+
old = (
567+
"\t\t} catch ( PDOException $e ) {\n"
568+
"\t\t\tif ( str_contains( $e->getMessage(), 'no such table' ) ) {\n"
569+
"\t\t\t\t// The table might not exist if no sequences are used in the DB.\n"
570+
"\t\t\t} else {\n"
571+
"\t\t\t\tthrow $e;\n"
572+
"\t\t\t}\n"
573+
"\t\t}"
574+
)
575+
new = (
576+
"\t\t} catch ( PDOException $e ) {\n"
577+
"\t\t\tif (\n"
578+
"\t\t\t\tstr_contains( $e->getMessage(), 'no such table' )\n"
579+
"\t\t\t\t|| str_contains( $e->getMessage(), 'may not be modified' ) // Turso\n"
580+
"\t\t\t) {\n"
581+
"\t\t\t\t// Table missing, or write forbidden (Turso). Ignore.\n"
582+
"\t\t\t} else {\n"
583+
"\t\t\t\tthrow $e;\n"
584+
"\t\t\t}\n"
585+
"\t\t}"
586+
)
587+
assert old in src, 'sqlite_sequence catch not found'
588+
src = src.replace(old, new, 1)
589+
open(path, 'w').write(src)
590+
print('patched sqlite_sequence catch')
591+
592+
# 5. wp_die polyfill: real WordPress provides wp_die(); the unit-test
564593
# bootstrap doesn't, so tests hit an 'undefined function' error when
565594
# a driver error path tries to call it.
566595
path = 'tests/bootstrap.php'

0 commit comments

Comments
 (0)