Repository navigation
Commit 3ff7fb7
refactor(driver-sql, plugin-security): read the list-comparand split from @objectstack/spec/data (#29660)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ86whSn5a9tBQC9Cw4hccB47)_
Fixes #29611
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:`driver-sql` 的 `sql-driver.ts` 与 `plugin-security` 的
`rls-check-stored-form.ts` 删掉各自手抄的 `LIST_COMPARAND_OPERATORS`(`$in` /
`$nin` / `$between`),改为调用 `@objectstack/spec/data` 导出的
`isListComparandOperator`。
- 为什么改:#29419 已把这条运算符拆分收归 spec 一处;这两份副本是剩下的漂移点。spec 的列表运算符一变,SQL
驱动的成员绑定检查和 RLS 存储形态检查会静默跟丢。
- 风险与回滚:行为不变。改动前已实测两份本地集合与 spec 谓词在 43 个拼写上逐一答案相同;两包现有测试全绿。回滚即撤销本 PR。
-
先看:`packages/plugins/plugin-security/src/rls-check-stored-form.ts`(`storedOperand`
一行替换),`packages/drivers/driver-sql/src/sql-driver.ts`(`assertCompilableComparand`
成员循环一行替换,加导入)。
- 两分钟验证:`git grep -n LIST_COMPARAND_OPERATORS --
packages/drivers/driver-sql packages/plugins/plugin-security`,预期零命中(退出码
1)。
- 需要你做的:无,席位落地。
## What changes
- **`packages/drivers/driver-sql/src/sql-driver.ts`**:
`assertCompilableComparand` bind-tests each member of a list operator's
array only when `isListComparandOperator(op)` answers true. The
module-private `LIST_COMPARAND_OPERATORS` and its docblock are removed.
The docblock's reason (a scalar operator handed an array keeps its own
"requires a single comparable value" message) moves into the call-site
comment. A new import line from `@objectstack/spec/data` carries a
comment in the file's existing style, and the `{@link}` in the scalar
set's docblock now names the predicate.
- **`packages/plugins/plugin-security/src/rls-check-stored-form.ts`**:
`storedOperand` asks `isListComparandOperator(op)`, added to the
existing `@objectstack/spec/data` import. The module-private copy is
removed. The `VALUE_COMPARISON_OPERATORS` docblock now says the list
half is the spec's answer. That set is unchanged: it is a different
question (which operators compare with the stored value), and the card
does not move it.
- **Changesets**:
`.changeset/29611-driver-sql-list-comparand-predicate.md`
(`@objectstack/driver-sql` patch) and
`.changeset/29611-plugin-security-list-comparand-predicate.md`
(`@objectstack/plugin-security` patch), each with both declaration
lines.
- No `packages/spec` edit. No `protocol.ts` file is touched.
## Tests
- No test changed. Neither package had a test that only reconciled its
copy against the spec, so there was nothing to delete.
- The existing suites cover both call sites (for example
`sql-driver-compile-refusal-seam.test.ts` for the list-member bind
refusal) and stay green.
- No ablation: the diff changes no tested behaviour, so the equality
reading below stands in for one.
## Acceptance notes
- **Equality before the swap.** On base `4d8095ba`, a scratch script
read each local set from source and compared it with the built spec
predicate over 43 spellings: the 19 operators `FieldOperatorsSchema`
declares, plus 24 others (the infix spellings `=`, `==`, `!=`, `<>`,
`>`, `>=`, `<`, `<=`, `like`, `ilike`; `in`, `nin`, `not in`, `between`;
`$and`, `$or`, `$not`, `$field`, `$IN`; the empty string; and
`constructor`, `__proto__`, `toString`, `hasOwnProperty`). Both sets
answered exactly as `isListComparandOperator` on every spelling, and
each holds `$in`, `$nin`, `$between`. The spec export covers every case
the local copies handled. The script was not committed.
- Both packages already depend on `@objectstack/spec` (`workspace:*`)
and import from `@objectstack/spec/data`, so no manifest changes.
- `driver-sql` keeps its other local operator sets
(`SCALAR_COMPARAND_OPERATORS` with infix spellings,
`TEXT_PATTERN_OPERATORS`, `LIKE_PATTERN_OPERATORS`). They are
driver-specific and outside this card.
## Verification
Readings on head `19e661f7`, which merges `origin/main` `3482f3d8` into
the change commit `a7214859` (base `4d8095ba`). Each reading was also
taken on `a7214859` before the merge, with the same results except where
noted.
<details><summary>Tests and typecheck</summary>
- Under the verify lock on `19e661f7`: `pnpm install --frozen-lockfile`,
then `pnpm exec turbo run build --filter=!@objectstack/docs
--concurrency=2`, 117/117 tasks, `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/driver-sql --filter
@objectstack/plugin-security typecheck`: `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/plugin-security test`: 241 files passed,
5203 tests passed, 45 skipped, `VERDICT command-exit 0`. (5202 on
`a7214859`; the merge brought a reworked `it.each` table in
`default-row-scope-declarations.test.ts`, from #29575.)
- `pnpm --filter @objectstack/driver-sql test`: 236 files passed, 12
skipped; 3847 tests passed, 214 skipped, `VERDICT command-exit 0`.
- `test:repo` is not run locally (no file of that project changed); it
is CI's `Test Core`.
</details>
<details><summary>Derived gates and lint</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on `19e661f7` derived 60 families. All 60
ran, each exit 0, exit codes captured before any pipe. `--ran`
reconciliation: "60 derived, 60 run, 0 NOT-MEASURED, 0 UNRUN", exit 0,
no stale-tree warning.
- On `a7214859` the same derivation gave 61 families (the extra one,
`check:pm-changeset-deadline-census`, was retired on `main` by #29577).
There, `check:dual-build-cjs-loads` and `check:i18n` first exited 3
(PREREQUISITE NOT MET: no `dist/` outside this diff's closure). After a
full build both exited 0, and the reconciliation read 61 of 61 run. That
run also warned the tree was 10 commits behind `origin/main`, which is
why the branch merged `main` and every reading was taken again.
- `pnpm lint` (repo-wide eslint) exit 0 on both heads.
</details>
Dogfood battery: not run (no `!` in the title and no `(narrowing)` arm).
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No spec change.)
- [x] 2. Every name I added uses the casing for its kind. (No new
names.)
- [x] 3. No formatter ran; `pnpm lint` passes (local run, exit 0).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: not touched, nothing to regenerate.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbYnNFzqeb7KM8Lpd7j)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent a2f77f7 commit 3ff7fb7
4 files changed
Lines changed: 37 additions & 20 deletions
File tree
- .changeset
- packages
- drivers/driver-sql/src
- plugins/plugin-security/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
2487 | 2492 | | |
2488 | 2493 | | |
2489 | 2494 | | |
2490 | | - | |
| 2495 | + | |
2491 | 2496 | | |
2492 | 2497 | | |
2493 | 2498 | | |
| |||
2569 | 2574 | | |
2570 | 2575 | | |
2571 | 2576 | | |
2572 | | - | |
2573 | | - | |
2574 | | - | |
2575 | | - | |
2576 | | - | |
2577 | | - | |
2578 | | - | |
2579 | | - | |
2580 | | - | |
2581 | | - | |
2582 | | - | |
2583 | 2577 | | |
2584 | 2578 | | |
2585 | 2579 | | |
| |||
2687 | 2681 | | |
2688 | 2682 | | |
2689 | 2683 | | |
2690 | | - | |
2691 | | - | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
2692 | 2689 | | |
2693 | | - | |
| 2690 | + | |
2694 | 2691 | | |
2695 | 2692 | | |
2696 | 2693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| 166 | + | |
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| |||
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
182 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
183 | 186 | | |
184 | 187 | | |
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| |||
0 commit comments