Skip to content

fix(driver-sql): distinct and aggregate group keys present a text boolean as find() does - #35332

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34974-boolean-read-presenter
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34974-boolean-read-presenter

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #34974

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:SQLite 上布尔/开关字段在 distinct() 和聚合分组键里,存储的文本 '0' / 'false' 现在显示为 false,'1' / 'true' 显示为 true,与记录读取(find())完全一致;用的是记录读取同一个函数,不是另写一套规则。
  • 为什么改:此前这两个出口用 Boolean(value),文本 '0' 会被当成 true。对于由文本字段改成布尔字段的列(SQLite 保留 TEXT 亲和性),所有未勾选的行在仪表盘分组里都会算进 true 桶,distinct 也只答 [true]。
  • 风险与回滚:只影响 SQLite / MySQL / Oracle 上布尔字段的 distinct 和分组键显示;数字与布尔值的显示不变,其他文本照旧。回滚即还原一行代码,无数据改动。
  • 先看:packages/drivers/driver-sql/src/sql-driver-filter-helpers.ts(presentReadValue 的 'boolean' 分支)、packages/drivers/driver-sql/src/sql-driver-sqlite-serialisation.ts(presentStoredBoolean 改为导出)、packages/drivers/driver-sql/src/sql-driver-34974-boolean-read-presenter.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-34974-boolean-read-presenter.test.ts,预期 10 个测试全部通过。
  • 需要你做的:无,席位落地。

What changes

Tests

New file packages/drivers/driver-sql/src/sql-driver-34974-boolean-read-presenter.test.ts, 10 tests on two columns:

  • INTEGER column (created by the driver, legacy text 'true' / 'false' written past the driver, not yet converged): fixture storage types, find() as the reference, distinct() answers [false, true], group key and aliased group key present the text 'false' as false.
  • TEXT-affinity column (raw flag text column, legacy 'false' / 'true' plus a '0', then a boot): the fixture shows the boot leaves every cell as the text '0' / '1'; find() as the reference; distinct() answers [false, true]; group key and aliased group key count [[false, 3], [true, 1]].
Reading first: the TEXT-affinity case live on SQLite, before the fix (origin/main de8d549)

The new file run against the unfixed presenter: 6 failed, 4 passed. The fixture and find() pins pass, and every distinct / group-key pin fails:

TEXT-affinity distinct():   expected [ true ] to deeply equal [ false, true ]
TEXT-affinity group key:    expected [ [ true, 3 ], [ true, 1 ] ] to deeply equal [ [ false, 3 ], [ true, 1 ] ]
INTEGER distinct():         expected [ true ] to deeply equal [ false, true ]
INTEGER group key:          expected [ [ true, 1 ], [ true, 1 ], …(1) ] to deeply equal [ [ false, 1 ], [ true, 1 ], …(1) ]
Ablation (one, on the committed fix)

node scripts/ablation-replace.mjs swapped return presentStoredBoolean(value); back to return Boolean(value); in sql-driver-filter-helpers.ts: anchor x1 to x0, blob 6ec738601bee to 77d0e0a57de7. Result: the new file goes 6 failed / 4 passed, the same six pins as the reading above. Restore: blob back to 6ec738601bee, equal to HEAD, and git diff HEAD empty. The test imports ./sql-driver.js from src, so no dist rebuild was involved.

Package suite
  • pnpm --filter @objectstack/driver-sql test: Test Files 264 passed, 13 skipped (277); Tests 4397 passed, 257 skipped (4654).
  • pnpm --filter @objectstack/driver-sql typecheck: exit 0. tsc --listFiles includes the new test file (1 hit).

Acceptance notes

  • Premise check: readPresentationKind already returned 'boolean' for a declared boolean on SQLite / MySQL / Oracle, so the card body's "no boolean kind" was stale. The live defect was the Boolean(value) arm, as the triage widening said.
  • Boot convergence (fix(driver-sql): boot converges legacy text booleans on SQLite to 1 / 0 #35076) does not remove the case. On a TEXT-affinity column the convergence writes 0 / 1 for a legacy 'false' / 'true', and the affinity stores that as the text '0' / '1'. It leaves the text '0' / '1' in place on purpose, because those already read correctly on a row. So a TEXT-affinity column holds '0' after every boot.
  • Separate finding, not fixed here: on SQLite, a field retyped from text to boolean keeps its TEXT column after the boot (pragma_table_info reads TEXT before and after). The driver's own create(…, { flag: false }) then stores the text '0.0' (better-sqlite3 binds the number as REAL), and find() presents it as true, along with distinct() and group keys. The same column also misses '0' rows on flag = false. This is out of this card's scope: fixing it means either reading '0.0' / '1.0' as booleans in the shared presenter, which changes find() and adds a new truthiness rule, or converging or rebuilding the column's storage. That is a design choice, so it goes to the seat in the report.

Verification

Local gates and CI check-runs are cited in the os-dev report on the card. node scripts/pm/overlap-check.mjs --branch=HEAD: clean, exit 0.


Generated by Claude Code

…lean as find() does

presentReadValue's 'boolean' arm was Boolean(value), so a stored text '0' / 'false'
(a TEXT-affinity boolean column, or legacy text a boot has not converged) presented
as true in distinct() and aggregate() group keys while find() read it as false.
The arm now calls presentStoredBoolean, the function formatOutput applies.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
… false as false

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 15 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 81c09477981398c908cc282e7c2c9a0fec884278 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from c12f12ff7f15e0a2992f03bd7cfbc5a5bf100f7b — the merge of head c057c311b4f8ed3b8ec8230b0fe6272fa003f756 into base 81c09477981398c908cc282e7c2c9a0fec884278, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin c12f12ff7f15e0a2992f03bd7cfbc5a5bf100f7b && git checkout c12f12ff7f15e0a2992f03bd7cfbc5a5bf100f7b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 81c09477981398c908cc282e7c2c9a0fec884278 c057c311b4f8ed3b8ec8230b0fe6272fa003f756 && git checkout -B drift-repro 81c09477981398c908cc282e7c2c9a0fec884278 && git merge --no-ff c057c311b4f8ed3b8ec8230b0fe6272fa003f756

node scripts/docs-audit/affected-docs.mjs --json 81c09477981398c908cc282e7c2c9a0fec884278

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

Final head for review · area data-1 · 2026-11-19T05:41Z
Head: c057c311b4f8ed3b8ec8230b0fe6272fa003f756 — every third-party check suite on it completed with no failure.
Fixes #34974 · Clause-②: no · Metadata-protocol: none · +169/−4 over 5 files (claim amendment 7000752799 adds two in-package files).
Review route: L1-a thread. Landing after its ACCEPT, by the area.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:在 SQLite 部署上,按「是/否」字段分组统计或列出不重复取值时,原来存成文字「否」的记录不再被算进「是」,和打开记录时看到的一致。
  • 为什么做:修数据层的一个遗留问题——是/否字段在列表记录里读得对,在分组和去重统计里读错。
  • 出错会怎样:只影响 SQLite 上是/否字段的分组与去重结果;Postgres 不受影响,回滚本改动即可恢复原样。
  • 要你做什么:无。

席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head c057c311b4f8ed3b8ec8230b0fe6272fa003f756 · 2026-11-19T05:43Z

  • 形态: draft → main, 5 files, +169/−4. Fixes #34974. check-governed-merges --pr 35332: 0 of 5 paths governed, 173 lines ≤ 3000 → ordinary queue landing.
    • Clause-②: no holds. presentStoredBoolean is newly exported from sql-driver-sqlite-serialisation.ts, but @objectstack/driver-sql's exports map is . only, and the entry does not re-export that module. So the export is internal, not published surface.
    • Metadata-protocol: none.
  • Fixes vs the card: the card's premise ("no boolean kind") is out of date on this base: presentReadValue already had a 'boolean' arm, but it was Boolean(value). What remained was the text '0'/'false' reading as true. The arm now calls the exact function formatOutput applies to a find() row, which is one presenter for every door. Done-when, "distinct over a boolean column returns true/false on SQLite", is pinned for both an INTEGER column holding text and a TEXT-affinity column. So Fixes is right.
  • Correctness:
    • value == null returns before the switch, so null is untouched.
    • Integers 0/1 and real booleans read as before through Boolean(value). Only the four text spellings change, so Postgres and MySQL answers are unchanged for real booleans and tinyint.
    • min/max/sum/avg take the number arm, not this one.
  • Changeset: .changeset/34974-boolean-read-presenter.md, patch on @objectstack/driver-sql. I read each sentence against the diff:
    • "TEXT affinity ... rows a boot has not converged yet still hold the legacy text" matches the two fixtures.
    • "Record reads presented those values as their boolean, but distinct() and an aggregate() group key presented them as Boolean(value)" matches the old arm.
    • The read table (0/'0'/'false' → false, 1/'1'/'true' → true, any other value as before) matches presentStoredBoolean.
    • "Postgres is unchanged" and "min / max / sum / avg ... still answer a number" both hold.
  • 接受的偏差:
    1. On a column whose rows have not converged (text and integer cells mixed), SQL still groups the raw cells apart. A group-by can answer two buckets that both read false (or true). The new pin and the amended Inline grid edit stores a boolean field as the text 'true' (SQL driver) — equality filters miss it and requiredWhen reads it as false #34916 pin state this. It is no longer a wrong label, and it clears once the boot converges the column (data: normalise boolean fields already stored as the text 'true'/'false' (SQL driver), so equality filters find rows written before #34965 #34973). The changeset makes no merge claim, so nothing is owed.
    2. The amended Inline grid edit stores a boolean field as the text 'true' (SQL driver) — equality filters miss it and requiredWhen reads it as false #34916 reverse pin's comment says why its expected value flipped. The claim amendment 7000752799 covers that pin and the new export.
  • Pins:
    • The INTEGER column with text 'true'/'false': find() is the reference, distinct() answers [false, true], and the plain and aliased group keys present text false as false.
    • The TEXT-affinity column after boot: the fixture holds text '0'/'1', distinct() answers [false, true], and the plain and aliased group keys give [[false, 3], [true, 1]].
  • 门禁: check-runs on head c057c311: 37 success, 16 skipped (the UI legs, out of path), 0 failure. The successes include Test Core and all 10 shards, Build Core, Type Check (workspace, source and consumer gates), Lint & Repo Gates, and Check Changeset.
  • 范围外去向: none.
  • 落地条款: K = 9 first-parent commits on main since merge base de8d5497 (< 15). No locale pack. Non-governed ⇒ data-1 lands per landing-operations.md (pr_ready + auto-merge) after this ACCEPT. On MERGED, close-out on driver-sql: presentReadValue has no boolean kind, so distinct and aggregates over a boolean column show raw 1/0 (or legacy 'true'/'false') on SQLite #34974.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

Landing · area data-1 · 2026-11-19T05:44Z

reading value
L1-a ACCEPT comment 7000891060 at head c057c311b4f8ed3b8ec8230b0fe6272fa003f756 (= current head)
check-governed-merges --pr 35332 NOT governed, 0 of 5 paths, 173 lines ≤ 3000; K = 9 from merge base de8d5497 (< 15), no locale pack

State: draft → ready + auto-merge (merge queue). #34974 closes on merge via Fixes.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 19, 2026 05:44
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 24cc61f Nov 19, 2026
54 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34974-boolean-read-presenter branch November 19, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

driver-sql: presentReadValue has no boolean kind, so distinct and aggregates over a boolean column show raw 1/0 (or legacy 'true'/'false') on SQLite

2 participants