Repository navigation
fix(driver-sql): a boolean retyped from text stores 1 / 0 on SQLite, so a saved false no longer reads as true - #35511
Conversation
…and the boot converges 1.0 / 0.0 A text field retyped to boolean keeps its TEXT column on SQLite. knex binds a JS boolean as a number, better-sqlite3 binds a number as REAL, and TEXT affinity kept it as the text '1.0' / '0.0', which the row read presented as true both. The write and the filter comparand of a declared scalar boolean now bind the text '1' / '0' (NUMERIC affinity folds it to the integer 1 / 0; TEXT keeps the spelling the boot convergence writes), and the convergence rewrites existing '1.0' / '0.0' rows. Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-Authored-By: Claude <noreply@anthropic.com>
…SQLite Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb Co-Authored-By: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 15 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 9ba9c48179657f76d136edbf6eeb9952c9e21e18 && git checkout 9ba9c48179657f76d136edbf6eeb9952c9e21e18
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 578d3b1d66c93bb5b9e1d113bf0d73501274aa3c 52e9b07a63ac07dbce1007e898292056503320ab && git checkout -B drift-repro 578d3b1d66c93bb5b9e1d113bf0d73501274aa3c && git merge --no-ff 52e9b07a63ac07dbce1007e898292056503320ab
node scripts/docs-audit/affected-docs.mjs --json 578d3b1d66c93bb5b9e1d113bf0d73501274aa3c
|
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对L1-a: ACCEPT · head Readings: Code (driver-sql only, 5 files, +271/−13).
Pins.
Three ablations (the write bind, the comparand, and the convergence predicate) each went red, with the CONTROL green in all three. A0 at the REST door shows main storing The judgment asked: the sqlite-wasm / turso reading is accepted without a measurement. The fix binds text, and every SQLite client can bind text. What turns Declaration: agreed. Routing. Not governed, no contract face: data-1 merges main (K=20), then lands on green. A merge-only push needs no fresh L1. |
K=20 against main per L1-a; merge-only. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
|
repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb Landing · area data-1 · 2026-11-19T13:53Z
State: draft → ready + auto-merge (merge queue). #35341 closes on merge via |
repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb
Fixes #35341
Clause-②: no
Metadata-protocol: none
维护者速读
席位核对
sql-driver-sqlite-serialisation.ts(the newsqliteBooleanBindingand its use at the end offormatInput), then the comparand branch at the top ofcoerceFilterValueinsql-driver-filter-helpers.ts, then the widenedSQLITE_LEGACY_BOOLEAN_TEXTand theUPDATEinbackfillCanonicalBooleans(sql-driver-schema-sync.ts).pnpm --filter @objectstack/driver-sql exec vitest run --maxWorkers=2 src/sql-driver-35341-retyped-boolean-text-column.test.tsanswers 11/11 green; the CONTROL describe (a boolean column the driver created) shows the integer1/0storage unchanged.'1'/'0'and extending the boot convergence to'1.0'/'0.0'makesfind(),distinct()and= falseagree on new and existing rows, sopresentStoredBooleanneeds no widening (AGENTS.md Prime Directive 12) and the stored form converges on one spelling, the direction of PR fix(driver-sql): boot converges legacy text booleans on SQLite to 1 / 0 #35076.What changes
On SQLite, a
textfield retyped tobooleankeeps its TEXT column. knex's better-sqlite3 client binds a JS boolean asNumber(b), better-sqlite3 binds a JS number as a REAL, and TEXT affinity keeps the REAL as the text'0.0'/'1.0', whichpresentStoredBooleanread astrueboth.formatInput(SQLite only) binds a declared scalar boolean (booleanFields) that holds a JS boolean as the text'1'/'0'(sqliteBooleanBinding). NUMERIC affinity (a column the driver created) folds it into the INTEGER1/0, unchanged from before; TEXT affinity keeps'1'/'0', the spelling the boot convergence writes and the presenter reads. Every write door runs throughformatInput: create, update, upsert, bulkCreate, bulkUpdate, updateMany.coerceFilterValuebinds a boolean comparand on the same fields the same way, so= false/= true/$in/$neselect the rows the row read presents as that boolean.SQLITE_LEGACY_BOOLEAN_TEXT(the backfill's count, sample,UPDATEand theos migrate planpreview all read it) now also selects'1.0'/'0.0', and theUPDATEmaps them to1/0. They were counted as withheld and warned about before.str.replace is not a function).Tests
New pin: sql-driver-35341-retyped-boolean-text-column.test.ts, 11/11 green
Three describes: the retyped TEXT column written through all six write doors (storage is the text
1/0;find(),distinct(),= false,= true,$ne,$inagree); a retyped column holding'0.0'/'1.0'/'0'across a boot (the plan counts 2 rows asnormalize_boolean_storage, the boot rewrites them, withholds nothing, and the reads and filter agree); CONTROL, a boolean column the driver created (INTEGER1/0, answers unchanged).Ablation, one arm per mechanism (scripts/ablation-replace.mjs; the test imports src, no dist on the path)
copy[field] = v;): anchor 1 to 0, blob 70f2a4d38a7c to aadb818335c5; 5 failed / 6 passed (storage, find, distinct, filters red; CONTROL green). Restored: blob == HEAD,git diff HEADempty.return value;): blob 21ac54f81c71 to 528a57d1a45e; 3 failed / 8 passed (= false/= true,$ne/$in, the existing-rows filter red). Restored.('true', 'false'): blob 66b443f687f8 to 3886962a9261; 3 failed / 8 passed (plan count, boot rewrite, existing-rows agreement red). Restored.driver-sql package suite and typecheck
pnpm --filter @objectstack/driver-sql test(lock VERDICT command-exit 0, tree 5d191fa; the later head af25ec3 adds only the changeset): Test Files 265 passed, 13 skipped (278); Tests 4408 passed, 257 skipped (4665).pnpm --filter @objectstack/driver-sql typecheck: exit 0 (tsconfig includessrc/**/*, so the new test is compiled).Acceptance notes
textthen retyped toboolean; the example edit was a scratch edit, reverted, not in this diff). See Verification.isSqliteand so take the same bind. sql.js already bound an integer-valued number as INTEGER, so a TEXT column there stored'0'before this change and stores'0'after; this was reasoned from sql.js's binder, not measured here.0/1(not a JS boolean) handed straight to the driver is not rebound; the engine's boolean arm hands the driver JS booleans.Verification
A0, the REST data door, origin/main 6f36818 vs this branch
Before (origin/main): after the retype boot,
pragma_table_inforeadsprobe_flagTEXT.POST /api/v1/data/todo_taskwithprobe_flag: falseanswers 201 with"probe_flag":true; the cell is the text'0.0'(and'1.0'for true). The list reads both rows astrue; theprobe_flag = falsefilter returns the false row, presented astrue.After (driver-sql rebuilt at af25ec3, same database file): the boot rewrote the two rows to
'0'/'1'.POSTwithfalseanswers"probe_flag":falseand stores'0'. The list reads[door_false,false],[door_true,true],[post_false,false],[post_true,true]; the= falsefilter returns exactlydoor_falseandpost_false, bothfalse.A1 to A3, measured on origin/main 6f36818 at the driver
client-better-sqlite3_formatBindingsmaps a boolean toNumber(b); better-sqlite3 13.0.3 binds it as REAL. On the retyped TEXT column, create, update, bulkCreate and updateMany all stored'0.0'/'1.0'; on an INTEGER-form column,0/1.backfillCanonicalBooleanswrites the integer1/0, which a TEXT column stores as the text'1'/'0'.'0.0'/'1.0'were not in its population: a reboot loggedleft 7 row(s) of ... unconvertedand changed nothing.presentStoredBooleanreads'false'/'0'as false,'true'/'1'as true, anything else asBoolean(value), so'0.0'readstrue. The= falsecomparand bound as REAL compared as'0.0'on the TEXT column: it matched the'0.0'rows and missed the'0'row the convergence left.Local gates (derived with dispatch-gates.mjs --commands, run on head af25ec3)
68 families derived for the 5 changed paths; 66 exit 0, 2 NOT MEASURED (exit 3, PREREQUISITE NOT MET):
pnpm check:dual-build-cjs-loads(reads every package's dist; no whole-repo build here) andpnpm check:type-check-debt(its re-measure build never got a turn on the shared verify lock). Both run in CI'sLint & Repo Gates.dispatch-gates.mjs --ranwith the exit codes recorded:✓ 68 derived famil(ies) accounted for — 66 run, 2 NOT-MEASURED.overlap-check.mjs --branch=HEAD:VERDICT clean exit 0.Generated by Claude Code