Skip to content

Commit 907b378

Browse 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>
1 parent b89f1b5 commit 907b378

8 files changed

Lines changed: 490 additions & 11 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/driver-sql': patch
3+
---
4+
5+
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.

‎packages/drivers/driver-sql/src/fixed-read-leaf-key-type.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@
7272
* old type until restart.
7373
*
7474
* Every other dialect is untouched: SQLite compares by column affinity (the
75-
* same rows, measured on step 3), and MySQL, SQL Server and Oracle are named
76-
* as left in the O2 card's report.
75+
* same rows, measured on step 3), MySQL and SQL Server are named as left in
76+
* the O2 card's report, and Oracle converts a `RAW(16)` uuid key's grants
77+
* itself (`oracleUuidRawProjection`, `sql-driver-oracle-dialect.ts`).
7778
*/
7879

7980
import type { Knex } from 'knex';

‎packages/drivers/driver-sql/src/sql-driver-filter-helpers.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,12 @@ export class FilterHelpersFacet {
860860
// `field IN (SELECT …)` (`SqlDriver#fixedReadLeafSubquery`), under the
861861
// outer statement's own wall and nothing else. `applyFilters` refused
862862
// it at every other position. The object and column it is compared
863-
// with type the inner read on PostgreSQL (ADR-0155 O2).
863+
// with type the inner read on PostgreSQL (ADR-0155 O2); on Oracle a
864+
// RAW(16) uuid column, read as the list's `HEXTORAW` binding reads it.
864865
if (rawOp === '$in' && isFixedReadLeaf(opValue)) {
865866
const mIn = logicalOp === 'or' ? 'orWhereIn' : 'whereIn';
866-
(builder as any)[mIn](field, this.fixedReadLeafSubquery(opValue, { object: table, column: field, evaluator: this.readableIdsDriverName, transaction: options?.transaction }));
867+
const oracleRawUuid = this.isOracle && this.oracleRawUuidFieldsByObject.get(table ?? '')?.has(localField) === true;
868+
(builder as any)[mIn](field, this.fixedReadLeafSubquery(opValue, { object: table, column: field, evaluator: this.readableIdsDriverName, oracleRawUuid, transaction: options?.transaction }));
867869
continue;
868870
}
869871
// #5222 — a `{ $field }` that is the WHOLE comparand of a scalar

‎packages/drivers/driver-sql/src/sql-driver-fixed-read-leaf-conformance.test.ts‎

Lines changed: 364 additions & 2 deletions
Large diffs are not rendered by default.

‎packages/drivers/driver-sql/src/sql-driver-internal-helpers.ts‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ import type { Knex } from 'knex';
4040
import type { SqlDriver } from './sql-driver.js';
4141
import { fixedInnerReadPredicates } from './fixed-read-leaf-compile.js';
4242
import { castFixedReadLeafColumn, fixedReadLeafKeyReading, refuseFixedReadLeafKey } from './fixed-read-leaf-key-type.js';
43+
import { oracleUuidRawProjection } from './sql-driver-oracle-dialect.js';
44+
45+
/** What a fixed-read leaf's `$in` arm says of the outer column the subquery is compared with. */
46+
export interface FixedReadLeafOuter {
47+
/** The outer object (the filter compiler's coercion key), `null` when unknown. */
48+
readonly object: string | null;
49+
/** The outer column, as the statement spells it. */
50+
readonly column: string;
51+
/** The driver named as the evaluator in a PostgreSQL no-reading refusal (`refuseFixedReadLeafKey`). */
52+
readonly evaluator?: string;
53+
/** PostgreSQL: the caller's transaction, on whose connection the key type is read (`fixedReadLeafKeyReading`). */
54+
readonly transaction?: unknown;
55+
/**
56+
* Oracle: the outer column is a `RAW(16)` uuid column, the same reading
57+
* (`oracleRawUuidFieldsByObject`, same object and field) that makes the
58+
* list bind its members as `HEXTORAW(?)`.
59+
*/
60+
readonly oracleRawUuid?: boolean;
61+
}
4362

4463
/**
4564
* The `SqlDriver` members the bodies of {@link InternalHelpersFacet} read — every one of
@@ -185,8 +204,17 @@ export class InternalHelpersFacet {
185204
* connection, `outer.transaction`) is refused, ADR-0139 D3's
186205
* envelope (`INTERNAL_ERROR` / 500, logged once), ⛔ never compiled
187206
* uncast: a `character(n)` key would miss a padded grant silently (D2).
207+
* - **Oracle, a `RAW(16)` uuid key (O2, ruling A carried to Oracle).** Where
208+
* `outer.oracleRawUuid` says the list binds its members as `HEXTORAW(?)`,
209+
* the projection is the same conversion over the column, behind the
210+
* list's own gate (`oracleUuidRawProjection`): a grant `UUID_TEXT` admits
211+
* is the 16 bytes the list binds; any other grant fails the statement
212+
* (ORA-01465), as the list refuses it before SQL.
213+
* Any other Oracle key projects `record_id` as before (a `NUMBER` key
214+
* converts it the way it converts the list's text binds). Oracle has no
215+
* no-reading refusal: an unprimed key compiles as the list's text binds do.
188216
*/
189-
static fixedReadLeafSubquery(this: Pick<InternalHelpersHost, 'getBuilder' | 'isOracle' | 'knex' | 'logger' | 'physicalSchemaByObject' | 'physicalTableByObject'>, leaf: FixedReadLeaf, outer?: { readonly object: string | null; readonly column: string; readonly evaluator?: string; readonly transaction?: unknown }): Knex.QueryBuilder {
217+
static fixedReadLeafSubquery(this: Pick<InternalHelpersHost, 'getBuilder' | 'isOracle' | 'knex' | 'logger' | 'physicalSchemaByObject' | 'physicalTableByObject'>, leaf: FixedReadLeaf, outer?: FixedReadLeafOuter): Knex.QueryBuilder {
190218
const read = fixedInnerReadPredicates(leaf, { emptyStringIsNull: this.isOracle });
191219
let projection: string | Knex.Raw = read.column;
192220
// [ADR-0155 O2] PostgreSQL only: the physical table as `getBuilder`
@@ -203,6 +231,8 @@ export class InternalHelpersFacet {
203231
}
204232
if (reading.kind === 'cast') projection = castFixedReadLeafColumn(this.knex, read.column, reading.cast);
205233
}
234+
// [ADR-0155 O2, ruling A carried to Oracle] A RAW(16) uuid key: the list's `HEXTORAW` conversion over the column.
235+
if (this.isOracle && outer?.oracleRawUuid === true) projection = oracleUuidRawProjection(this.knex, read.column);
206236
const inner = this.getBuilder(read.table).select(projection);
207237
for (const [column, value] of read.equals) inner.where(column, value);
208238
for (const [column, values] of read.memberOf) inner.whereIn(column, [...values]);

‎packages/drivers/driver-sql/src/sql-driver-oracle-dialect.ts‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,69 @@ export function oracleUuidRawBinding(
204204
throw err;
205205
}
206206

207+
/**
208+
* {@link UUID_TEXT} as an Oracle regular expression, for `REGEXP_LIKE` with
209+
* the match parameter {@link ORACLE_UUID_TEXT_MATCH}: derived from the one
210+
* constant, never restated, so the subquery's gate and the list's gate cannot
211+
* drift. Oracle's POSIX syntax has no `(?:…)`, so each non-capturing group is
212+
* written as a plain one (the same language). A pattern this derivation cannot
213+
* carry (a flag other than `i`, a `?` knex would read as a binding, a quote
214+
* that would end the SQL literal, a construct still Perl-only) throws at load.
215+
*/
216+
export const ORACLE_UUID_TEXT_PATTERN = oracleRegexFrom(UUID_TEXT, 'i');
217+
218+
/** `REGEXP_LIKE`'s match parameter for {@link ORACLE_UUID_TEXT_PATTERN}: {@link UUID_TEXT}'s `i` flag. */
219+
export const ORACLE_UUID_TEXT_MATCH = 'i';
220+
221+
function oracleRegexFrom(re: RegExp, flags: string): string {
222+
const pattern = re.source.replace(/\(\?:/g, '(');
223+
if (re.flags !== flags || /[?'\\]/.test(pattern)) {
224+
throw new Error(`[driver-sql] UUID_TEXT (/${re.source}/${re.flags}) has no Oracle REGEXP_LIKE spelling here: extend oracleRegexFrom.`);
225+
}
226+
return pattern;
227+
}
228+
229+
/**
230+
* [ADR-0155 O2, ruling A carried to Oracle] {@link oracleUuidRawBinding}'s
231+
* conversion written over a text COLUMN instead of a bound value: the
232+
* projection of a fixed-read leaf's inner read (`record_id`, `VARCHAR2`) when
233+
* the outer column it is compared with is a `RAW(16)` uuid column, as the
234+
* catalog reports it (`SqlDriver#primeOracleRawUuidColumns`, the prime the
235+
* list's binding reads).
236+
*
237+
* ```sql
238+
* "ID" IN (SELECT HEXTORAW(CASE WHEN REGEXP_LIKE("record_id", '<UUID_TEXT>', 'i')
239+
* THEN REPLACE("record_id", '-', '')
240+
* ELSE 'not-a-uuid' END)
241+
* FROM "sys_record_share" WHERE …)
242+
* ```
243+
*
244+
* - **Uuid text converts as the list binds it.** A grant {@link UUID_TEXT}
245+
* admits (8-4-4-4-12 or 32 undashed hex digits, either case) is the same 16
246+
* bytes `HEXTORAW(?)` binds for it in the list, so the leaf answers the
247+
* list's rows.
248+
* - **Anything else fails the statement, loudly.** Every grant the list
249+
* refuses before SQL (`INVALID_FILTER` / 400) projects `'not-a-uuid'`, which
250+
* `HEXTORAW` refuses: ORA-01465, `DATABASE_ERROR` / 500, the statement's
251+
* failure in place of the list's (ADR-0155 Consequences; option A: "a
252+
* malformed grant id fails the statement"). ⛔ Never a bare
253+
* `HEXTORAW(REPLACE(…))`: measured on Oracle Free 23ai, it converts 32
254+
* digits with misplaced dashes to a full key (a row the list refuses), left
255+
* pads 31 digits to 16 bytes (a row the list refuses), and turns a dash-only
256+
* grant into NULL, under which the negation answers no row.
257+
*
258+
* Without any projection Oracle compares the `RAW` column as its upper-case
259+
* hex text, which no dashed or lower-case grant equals: the leaf answers no row
260+
* and its negation every row, with no error.
261+
*/
262+
export function oracleUuidRawProjection(knexInstance: Knex, column: string): Knex.Raw {
263+
return knexInstance.raw(
264+
`HEXTORAW(CASE WHEN REGEXP_LIKE(??, '${ORACLE_UUID_TEXT_PATTERN}', '${ORACLE_UUID_TEXT_MATCH}') ` +
265+
`THEN REPLACE(??, '-', '') ELSE 'not-a-uuid' END)`,
266+
[column, column],
267+
);
268+
}
269+
207270
/** Whether `value` is uuid text a `RAW(16)` column can be bound to — see {@link UUID_TEXT}. */
208271
export function isOracleUuidText(value: unknown): value is string {
209272
return typeof value === 'string' && UUID_TEXT.test(value);

‎packages/drivers/driver-sql/src/sql-driver.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ import { ManagedDriftFacet } from './sql-driver-managed-drift.js';
280280
// [#29520 codemod] Schema Introspection: the methods of the same names below hand the bodies what they read (`SchemaIntrospectionHost`).
281281
import { SchemaIntrospectionFacet } from './sql-driver-schema-introspection.js';
282282
// [#29520 codemod] Internal helpers: the methods of the same names below hand the bodies what they read (`InternalHelpersHost`).
283-
import { InternalHelpersFacet } from './sql-driver-internal-helpers.js';
283+
import { InternalHelpersFacet, type FixedReadLeafOuter } from './sql-driver-internal-helpers.js';
284284
// [#29520 codemod] Filter helpers: the methods of the same names below hand the bodies what they read (`FilterHelpersHost`).
285285
import { FilterHelpersFacet } from './sql-driver-filter-helpers.js';
286286
// [#29520 codemod] Field mapping: the methods of the same names below hand the bodies what they read (`FieldMappingHost`).
@@ -414,8 +414,8 @@ export class SqlDriver implements IDataDriver {
414414
// (Turso's remote transport compiles the leaf with its own compiler).
415415
readableIdsLeaf: true,
416416
// [ADR-0155 D4] One subquery per `SharedRecordIds` leaf (`applyFilterCondition`)
417-
// on every dialect; same rows as the id list measured on SQLite and PostgreSQL
418-
// only (O2: `fixed-read-leaf-key-type.ts`). Turso's remote transport has its own.
417+
// on every dialect; same rows as the id list measured on SQLite, PostgreSQL, Oracle
418+
// (RAW(16), NUMBER) (O2: `fixed-read-leaf-key-type.ts`, `oracleUuidRawProjection`). Turso: its own.
419419
fixedReadLeaves: ['SharedRecordIds' as const],
420420
};
421421
}
@@ -6525,7 +6525,7 @@ export class SqlDriver implements IDataDriver {
65256525
return InternalHelpersFacet.readableIdsSubquery.call(internalHelpersHost.of(this), leaf, options);
65266526
}
65276527

6528-
private fixedReadLeafSubquery(leaf: FixedReadLeaf, outer?: { readonly object: string | null; readonly column: string; readonly evaluator?: string; readonly transaction?: unknown }): Knex.QueryBuilder {
6528+
private fixedReadLeafSubquery(leaf: FixedReadLeaf, outer?: FixedReadLeafOuter): Knex.QueryBuilder {
65296529
// [ADR-0155 D2, O2] The body lives in `sql-driver-internal-helpers.ts`, its docblock with it.
65306530
return InternalHelpersFacet.fixedReadLeafSubquery.call(internalHelpersHost.of(this), leaf, outer);
65316531
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"file": "packages/drivers/driver-sql/src/sql-driver-oracle-dialect.ts",
3+
"adrs": [
4+
"ADR-0155"
5+
],
6+
"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."
7+
}

0 commit comments

Comments
 (0)