Skip to content

Commit 7ced8d3

Browse files
committed
Preserve original SQL text in CREATE TRIGGER sqlite_master.sql
Turso reconstructs stored trigger SQL by serializing the AST, which normalizes all user-provided whitespace. Real SQLite preserves the original statement text. testColumnWithOnUpdate asserts the stored text still has its multi-line formatting. Use the `input` parameter that's already threaded through translate_inner instead of the AST-reconstructed form.
1 parent 7e880ca commit 7ced8d3

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,41 @@ jobs:
433433
print('patched delete.rs to allow DELETE FROM sqlite_sequence')
434434
PY_DELETE_SEQ
435435
436+
# CREATE TRIGGER: Turso reconstructs the stored sqlite_master.sql by
437+
# serializing the AST (trigger::create_trigger_to_sql), which loses
438+
# user-provided whitespace/formatting. Real SQLite preserves the
439+
# original text. testColumnWithOnUpdate asserts on the stored text;
440+
# use the raw input SQL that was already threaded into translate_inner.
441+
python3 - <<'PY_TRIGGER_SQL'
442+
p = 'core/translate/mod.rs'
443+
s = open(p).read()
444+
old = (
445+
" // Reconstruct SQL for storage\n"
446+
" let sql = trigger::create_trigger_to_sql(\n"
447+
" temporary,\n"
448+
" if_not_exists,\n"
449+
" &trigger_name,\n"
450+
" time,\n"
451+
" &event,\n"
452+
" &tbl_name,\n"
453+
" for_each_row,\n"
454+
" when_clause.as_deref(),\n"
455+
" &commands,\n"
456+
" );\n"
457+
)
458+
new = (
459+
" // Preserve original SQL text (matches real SQLite);\n"
460+
" // avoid AST reconstruction which loses whitespace.\n"
461+
" let _ = (\n"
462+
" &event, for_each_row, when_clause.as_deref(), &commands,\n"
463+
" );\n"
464+
" let sql = input.to_string();\n"
465+
)
466+
assert old in s, 'CreateTrigger reconstruction block not found'
467+
open(p, 'w').write(s.replace(old, new, 1))
468+
print('patched CreateTrigger to preserve original SQL text')
469+
PY_TRIGGER_SQL
470+
436471
echo '--- Patched stub! macro ---'
437472
sed -n '/macro_rules! stub/,/^}$/p' sqlite3/src/lib.rs
438473

0 commit comments

Comments
 (0)