You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 907b378
Browse filesBrowse the repository at this point in the historyBrowse files
feat(driver-sql): the share-grant subquery converts a RAW(16) uuid key on Oracle as the list binds it (ADR-0155 O2) (#36001)
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu
Fixes#35952
## 维护者速读
- 问题:Oracle 上主键用 RAW(16) 存 uuid 的表,共享子查询(ADR-0155 第 3
步)今天是**静默漏行**,不是卡片原以为的 ORA-01465 报错。实测(Oracle Free 23ai):子查询答 `[]`,计数
0,取反时反而答出全部行。
- 这一步做什么:按你在 #35906 裁的 A(按主键类型比较、结果同今天)补到 Oracle:子查询里先用和名单同一条 uuid
规则校验授权
id,合格的转成和名单一样的二进制形式,不合格的让整条语句报错。实测:名单接受的每种写法都同行;名单拒绝的每种写法,子查询都整句报错(名单
400,子查询 500 ORA-01465)。
- 合同审查认定这个差别(同为拒绝,只是状态码不同)不改变 D-0,不需要你决定。
- 要你做的:无。
## What changes
- `packages/drivers/driver-sql/src/sql-driver-oracle-dialect.ts`:
`oracleUuidRawProjection`, beside `oracleUuidRawBinding`: `HEXTORAW(CASE
WHEN REGEXP_LIKE(record_id, UUID_TEXT, 'i') THEN REPLACE(record_id, '-',
'') ELSE 'not-a-uuid' END)`. The Oracle pattern
(`ORACLE_UUID_TEXT_PATTERN`) is derived in one place from the list's own
`UUID_TEXT`, with a load-time guard so the two cannot drift. A grant the
list admits converts exactly as the list binds it; a grant the list
refuses fails the statement.
- `packages/drivers/driver-sql/src/sql-driver-filter-helpers.ts`: the
leaf's `$in` arm reads the existing RAW(16) prime
(`oracleRawUuidFieldsByObject`, primed at every Oracle door) and passes
`oracleRawUuid` down. Nothing about the prime is restated.
- `packages/drivers/driver-sql/src/sql-driver-internal-helpers.ts`:
`fixedReadLeafSubquery` projects the conversion on Oracle for a RAW(16)
uuid key only. The outer argument is now a named type,
`FixedReadLeafOuter`. #35906's PostgreSQL arm is untouched, and Oracle
never reaches its no-reading refusal (pinned).
- `sql-driver.ts` (stub signature, 10067 lines, unchanged count), one
ADR anchor file, changeset
`.changeset/35952-oracle-raw-share-grant-key.md` (driver-sql patch).
## Why
Ruling A on #35906 (7051669729): compare by the key's type, same rows as
today's list (ADR-0155 D-0). Seat 7 carried it to every dialect
`driver-sql` ships. Part of the ADR-0155 chain; it unblocks step 6
(#33787).
## Measured on live Oracle Free 23ai (testkit `ORACLE_CELL`)
Fixture: a RAW(16)-keyed table, grants upper-case dashed, lower-case
dashed and undashed, plus a blank grant.
| Case | List (today) | Leaf before | Leaf after |
|---|---|---|---|
| Upper-case + lower-case grants | `[U2, U1]` | `[]` | `[U2, U1]` |
| Undashed grant | `[U1]` | `[]` | `[U1]` |
| Negation | `[U3]` | every row | `[U3]` |
| Count | 2 | 0 | 2 |
| Nested under ReadableIds | `[c1, c2]` | `[]` | `[c1, c2]` |
| `NUMBER(10)` key (`'42'`, `'07'`, `' 7'`) | `[42, 7]` | `[42, 7]` |
`[42, 7]` (unchanged SQL) |
### A stored grant the list would refuse
The list judges each comparand before any SQL; the leaf now applies the
same `UUID_TEXT` check inside the statement. Measured on live Oracle
Free 23ai, each malformed grant stored beside a valid one, find and
negation:
| Stored grant `record_id` | List | Leaf before the gate | Leaf now |
|---|---|---|---|
| 31 hex digits | 400 | silent; one 31-digit form GAINED a row | 500
ORA-01465 |
| 33 hex digits, `0123`, `abc` | 400 | grant silently dropped | 500
ORA-01465 |
| 32 hex digits, misplaced dashes | 400 | MATCHED a row | 500 ORA-01465
|
| `-`, all dashes | 400 | negation silently empty | 500 ORA-01465 |
| blank, padded, not hex, braced, `urn:uuid:` | 400 | 500 ORA-01465 |
500 ORA-01465 |
| Every admitted form (dashed or undashed, any case) | rows | rows | the
list's rows |
The contract review (7058145514) ruled the loud class (list 400, leaf
500) no change to D-0: ADR-0155's Consequences and ruling A both say a
malformed grant fails the statement. The gate closes the classes it
ruled a change (M1), so nothing goes to the maintainer.
## Verification
- Head `869573acbdc023bd64e70dbaa3db7a0761683711`: `ca269e1fa4` (the
conversion) plus `869573acbd` (the M1 gate), on main after #35906 merged
as 850bcec.
- At `869573acbd`: conformance + key-type files live on Oracle + SQLite,
90 passed / 2 skipped, 27 live Oracle pins green. Full driver-sql suite
with Oracle, PG 16.15 and SQLite live: 5945 passed / 132 skipped, exit
0. Typecheck and eslint exit 0. `dispatch-gates --ran` 80 of 80 exit 0.
Ablation of the gate (the bare `HEXTORAW(REPLACE(…))`): exactly the 9
predicted pins go red; restored blob-equal.
- Earlier, at `ca269e1fa4`, live Oracle Free 23ai (`ORACLE_CELL`): the
conformance file at that head, 64 passed / 2 skipped (PG and MySQL not
provisioned), with its 14 live Oracle pins green; the full driver-sql
suite at that head (SQLite, Oracle env set) 4652 passed, exit 0. On
#35906's head with PG 16.15 also live: full driver-sql 5926 passed / 132
skipped.
- ⚠️ No CI lane provisions Oracle, so the 27 live Oracle pins never run
in CI, before or after merge. They were run here, against a local Oracle
Free 23ai container. CI's `Temporal Conformance` lane runs the live PG
and MySQL cells only.
- `pnpm --filter @objectstack/driver-sql typecheck` exit 0; eslint on
the changed files exit 0; driver-turso leaf conformance 54/54 (on
#35906's head).
- `dispatch-gates --ran` at `ca269e1fa4` after a full packages build: 80
derived, 80 run, 0 NOT-MEASURED, all exit 0. `check-changeset-no-major`
exit 0 (patch, `Clause-②: yes`, `Metadata-protocol: none`).
- Ablation (`scripts/ablation-replace.mjs`, restored blob-equal): the
Oracle projection switched off → 10 failed live (the RAW find/count,
negation/`$or`, predicate update, statement, nested, aggregate, the
three refused-grant pins and the RAW compile pin); NUMBER, never-primed
and other-dialect pins stay green.
Clause-②: yes
The compiled share-grant subquery changes its SQL on Oracle for a
RAW(16) uuid key, keeping D-0's same rows (ruled A).
Metadata-protocol: none
## Acceptance notes
- Filed #35960 (out of scope, pre-existing on main): the Oracle RAW(16)
prime never walks a composed ReadableIds scope's parent, so a
`controlled_by_parent` child read of a RAW-keyed parent misses silently,
even in today's list form, until something has read the parent. This
PR's nested pin primes the parent explicitly and says so.
- `.changeset/35906-pg-share-grant-key-type.md` says Oracle RAW(16) keys
are not measured. That was true for #35906; this PR's changeset states
the Oracle change. If both ship in one release, the CHANGELOG carries
both sentences.
- MySQL and SQL Server cells were not run here (no cell).
- L1 (7058114575) asked that step 6 (#33787) carry a precondition that
the producer writes only canonical uuid text into `record_id` for a
RAW(16)-keyed object. Recorded on #33787; with the gate, a non-canonical
grant now fails loudly instead. L1's N1 is done in `869573acbd`.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [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: n/a, not touched.
- [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.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(driver-sql): on Oracle the share-grant subquery converts `record_id` the way the id list binds a `RAW(16)` uuid key (ADR-0155 O2)
6
+
7
+
Clause-②: yes
8
+
Metadata-protocol: none
9
+
10
+
No visible change on its own: nothing writes a `SharedRecordIds` leaf yet. The sharing plugin starts writing it at ADR-0155's last step, and this makes that step answer the right rows on Oracle tables keyed by a `RAW(16)` uuid (`SYS_GUID()` keys).
11
+
12
+
-**Oracle, a `RAW(16)` uuid key.** The compiled subquery `id IN (SELECT record_id FROM sys_record_share WHERE …)` now projects the id list's own conversion when the compared column is a `RAW(16)` uuid column, the same catalog reading that makes the list bind its members as `HEXTORAW(?)`: `HEXTORAW(CASE WHEN REGEXP_LIKE(record_id, UUID_PATTERN, 'i') THEN REPLACE(record_id, '-', '') ELSE 'not-a-uuid' END)`. A grant in upper, lower or mixed case, dashed (8-4-4-4-12) or as 32 undashed digits, names the same row it names in the list. `UUID_PATTERN` is the list's own uuid-text check, written for Oracle from the same constant. Before, Oracle compared the column as its upper-case hex text: the subquery matched no row and its negation every row, with no error.
13
+
-**A grant the id list refuses fails the statement.** The list refuses a value that is not uuid text before any statement (`INVALID_FILTER` / 400). Every such stored grant fails the subquery's statement instead, with `DATABASE_ERROR` / 500 (ORA-01465), on the read and on its negation: hex of another length (31 or 33 digits, `0123`), 32 digits with dashes out of place, a grant of dashes only, a blank or a padded uuid, a braced uuid, or text that is not hex. None of them answers a row, and none empties a negation.
14
+
-**Unchanged.** Any other Oracle key compiles exactly as before; a `NUMBER` key converts each grant as it converts the list's text binds (measured: the same rows, and the same ORA-01722 for a grant that is not a number). Every other dialect compiles exactly as before.
"invariant": "ADR-0155 D-0, D2, O2 (ruling A carried to Oracle): where the outer column is a RAW(16) uuid column by the catalog prime the list's HEXTORAW(?) binding reads (`oracleRawUuidFieldsByObject`, same object and field), the fixed-read leaf's inner read projects `oracleUuidRawProjection`: HEXTORAW(CASE WHEN REGEXP_LIKE(record_id, ORACLE_UUID_TEXT_PATTERN, 'i') THEN REPLACE(record_id, '-', '') ELSE 'not-a-uuid' END), the pattern derived from the list's own UUID_TEXT gate. A grant UUID_TEXT admits is the same 16 bytes the list binds, so the leaf answers the list's rows; every grant the list refuses before SQL (INVALID_FILTER / 400) fails the statement (ORA-01465, DATABASE_ERROR / 500) on the read and its negation. A bare HEXTORAW(REPLACE(...)) is not the gate: it matches misplaced-dash and left-padded 31-digit grants and turns a dash-only grant into NULL, emptying the negation. Without any projection Oracle compares the RAW column as its upper-case hex text and the leaf silently answers no row (its negation every row). Any other Oracle key keeps step 3's statement."
0 commit comments