From a59b393f20c2942d14e6fd2f7227af80f82877c4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Sep 2026 16:05:54 +0000 Subject: [PATCH 1/2] test(cli): pin `multiple: true` agreement across the three generate surfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Red-first. The pin drives `os generate types`, `os generate migration --format sql` and `os generate migration` (typescript) on one config and asserts they give a flagged field ONE answer — an array TS type and a JSON column — mirroring `driver-sql`'s `createColumn`, which decides `multiple` before its per-type switch. The three generator functions gain a named export so the pin can drive them directly; `src/commands/generate.ts` is not a package entrypoint (`@objectstack/cli` exports only `.` and `./console`), so nothing is added to the published surface, and no emitted output changes in this commit. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_016yfqQh2dBgPAymYd7xipza --- .../generate-multiple-json-column.pin.test.ts | 265 ++++++++++++++++++ packages/cli/src/commands/generate.ts | 6 +- 2 files changed, 268 insertions(+), 3 deletions(-) create mode 100644 packages/cli/src/commands/generate-multiple-json-column.pin.test.ts diff --git a/packages/cli/src/commands/generate-multiple-json-column.pin.test.ts b/packages/cli/src/commands/generate-multiple-json-column.pin.test.ts new file mode 100644 index 0000000000..58be269868 --- /dev/null +++ b/packages/cli/src/commands/generate-multiple-json-column.pin.test.ts @@ -0,0 +1,265 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * THE #14829 PIN: one authored `multiple: true` field, three surfaces, ONE answer. + * + * ## The defect + * + * `multiple` appeared exactly FOUR times in `generate.ts`, and all four were on + * the TypeScript side (measured at `origin/main` 5bc2f2727a: + * `git grep -n multiple origin/main -- packages/cli/src/commands/generate.ts`): + * + * :562 function fieldTypeToTs(fieldType: string, multiple?: boolean) + * :564 return multiple ? `${base}[]` : base; + * :607 const tsType = fieldTypeToTs(fType, !!fieldDef.multiple); // os generate types + * :831 const tsType = fieldTypeToTs(fType, !!fieldDef.multiple); // os generate client + * + * Neither migration generator read it, and `fieldTypeToSql` did not even take + * the parameter. So ONE authored field produced two incompatible answers from + * one config in one run — `Field.lookup({ reference: 'account', multiple: true })` + * emitted `account?: string[]` from `os generate types` and a scalar + * `VARCHAR(36)` / `table.uuid('account')` column from the two migration + * generators. Nothing warns: the scaffold looks right, the generated + * TypeScript IS right, and only the column is wrong, so the first symptom is a + * write. That is the `#field-zoo` failure one layer out — there the DDL switch + * and `isJsonField` had drifted into two lists inside the driver; here the + * platform and the GENERATED DDL are the two lists. + * + * ## Which surface is authoritative, and why it is NOT `isMultiValueField` + * + * Measured on `origin/main`, the platform answers "which column does this field + * get" from the FLAG ALONE, before it looks at the type, and says so in three + * places: + * + * packages/drivers/driver-sql/src/sql-driver.ts `createColumn` + * `if (field.multiple) { this.jsonColumn(table, name); return; }` — stated + * above the `switch (type)`, so the element type never gets a vote. + * packages/drivers/driver-sql/src/sql-driver.ts `isJsonField` + * `JSON_COLUMN_TYPES.has(type) || !!field.multiple` + * packages/drivers/driver-sql/src/schema-drift.ts `fieldHasColumn` + * `if (field?.multiple) return true;` — under the comment "Mirrors + * `SqlDriver.createColumn` exactly … everything else — including `multiple` + * (a JSON column) — gets one." + * + * The spec's `isMultiValueField` is a DIFFERENT question with a different + * answer: it is the ADR-0104 D1 VALUE contract ("is the persisted value an + * array"), and it gates on `MULTI_CAPABLE_TYPES` — + * `MULTI_OPTION_TYPES.has(type) || (MULTI_CAPABLE_TYPES.has(type) && multiple)`. + * A generator that asked it instead would answer VARCHAR for a `text` field + * flagged `multiple: true` while the driver gives that same field a JSON + * column — reintroducing this very drift one notch narrower. `FieldSchema` + * does not refuse the combination either (`multiple` is a plain + * `z.boolean().default(false)` on every field; only `radio` + `multiple` is + * refused, by name, in `field.zod.ts`'s superRefine), and the CLI generators + * sit DOWNSTREAM of validation and explicitly serve the unvalidated authoring + * door. So the column authority is the driver's flag-first rule, and this pin + * asserts against that. + * + * `MULTI_CAPABLE_TYPES` is still imported here rather than transcribed — it is + * the roster this pin SWEEPS, so a type added to that spec class is measured on + * the day it lands. It is not the implementation's gate, and the type-blindness + * control below is what states the difference as an assertion. + * + * ## Anti-vacuity + * + * Every arm has a control, because a pin that measured nothing would pass + * loudest of all. The controls are separate `it` blocks with `control —` in + * their names, so a red run says in its own title whether the discriminating + * arm fired or merely the harness: the roster really loaded, the generators + * really emitted, and — the one that matters — the SAME type WITHOUT the flag + * still gets its scalar column, so "JSONB everywhere" cannot pass this file. + */ + +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +import { MULTI_CAPABLE_TYPES } from '@objectstack/spec/data'; +import { describe, expect, it } from 'vitest'; + +import { + generateMigrationSql, + generateMigrationTs, + generateTypesFromConfig, +} from './generate.js'; + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const DRIVER_SQL_SRC = path.resolve(HERE, '../../../drivers/driver-sql/src'); + +/** + * The types swept for the flag. The spec's multi-capable roster (imported, not + * restated) plus `text` — a type that is NOT in that roster and whose scalar + * answer is a varchar, which is what makes the type-blindness of the rule + * assertable rather than merely described. + */ +const FLAGGED_TYPES: readonly string[] = [...MULTI_CAPABLE_TYPES, 'text']; + +/** One object carrying, for each swept type, a flagged field and its scalar twin. */ +function probeConfig(): Record { + const fields: Record> = {}; + for (const type of FLAGGED_TYPES) { + fields[`multi_${type}`] = { type, multiple: true }; + fields[`single_${type}`] = { type }; + } + return { objects: { probe: { name: 'probe', label: 'Probe', fields } } }; +} + +const TYPES_OUT = generateTypesFromConfig(probeConfig()); +const SQL_OUT = generateMigrationSql(probeConfig()); +const TS_OUT = generateMigrationTs(probeConfig()); + +/** The `"name" TYPE` column body one field contributes to the SQL migration. */ +function sqlColumn(field: string): string { + const m = SQL_OUT.match(new RegExp(`^ {2}"${field}" (.+?),?$`, 'm')); + if (!m) throw new Error(`no SQL column emitted for ${field}`); + return m[1]; +} + +/** The `table.x('name')…` call one field contributes to the TS migration. */ +function tsColumn(field: string): string { + const m = TS_OUT.match(new RegExp(`^ {4}(table\\.\\w+\\('${field}'\\)).*$`, 'm')); + if (!m) throw new Error(`no TS migration column emitted for ${field}`); + return m[1]; +} + +/** The declared property type one field contributes to the generated interface. */ +function tsInterfaceType(field: string): string { + const m = TYPES_OUT.match(new RegExp(`^ {2}${field}\\??: (.+);$`, 'm')); + if (!m) throw new Error(`no interface member emitted for ${field}`); + return m[1]; +} + +describe('#14829 — `multiple: true` is one answer across all three surfaces', () => { + it('control — the spec multi-capable roster really loaded', () => { + expect(MULTI_CAPABLE_TYPES.size).toBeGreaterThanOrEqual(6); + for (const known of ['select', 'lookup', 'user', 'file', 'image']) { + expect(MULTI_CAPABLE_TYPES.has(known)).toBe(true); + } + // `text` is the type-blindness probe: it must NOT be in the roster, or the + // control below stops distinguishing the flag rule from the value rule. + expect(MULTI_CAPABLE_TYPES.has('text')).toBe(false); + }); + + it('control — all three generators really emitted a table for the probe', () => { + expect(TYPES_OUT).toContain('export interface ProbeRecord {'); + expect(SQL_OUT).toContain('CREATE TABLE IF NOT EXISTS "probe" ('); + expect(TS_OUT).toContain("await db.schema.createTable('probe'"); + // Non-vacuity for the readers: every swept field really reached the output. + expect(FLAGGED_TYPES.length).toBeGreaterThanOrEqual(7); + for (const type of FLAGGED_TYPES) { + expect(() => sqlColumn(`multi_${type}`)).not.toThrow(); + expect(() => tsColumn(`multi_${type}`)).not.toThrow(); + expect(() => tsInterfaceType(`multi_${type}`)).not.toThrow(); + } + }); + + it('control — the SAME type without the flag still gets its scalar column', () => { + // THE discriminating control. If this file could be satisfied by emitting a + // JSON column for everything, the arms below would prove nothing. + expect(sqlColumn('single_lookup')).toBe('VARCHAR(36)'); + expect(tsColumn('single_lookup')).toBe("table.uuid('single_lookup')"); + expect(sqlColumn('single_text')).toBe('VARCHAR(255)'); + expect(tsColumn('single_text')).toBe("table.string('single_text')"); + expect(tsInterfaceType('single_lookup')).toBe('string'); + }); + + for (const type of FLAGGED_TYPES) { + it(`${type} + multiple:true — array TS type AND a JSON column in both migrations`, () => { + const declared = tsInterfaceType(`multi_${type}`); + expect(declared, `os generate types must give a flagged ${type} an array type`) + .toMatch(/\[\]$/); + + expect( + sqlColumn(`multi_${type}`), + `os generate migration --format sql gave a flagged ${type} a scalar column while ` + + 'the platform stores it as JSON (driver-sql createColumn decides `multiple` before ' + + 'the type switch), and os generate types called it an array', + ).toBe('JSONB'); + + expect( + tsColumn(`multi_${type}`), + `os generate migration (typescript) gave a flagged ${type} a scalar column while ` + + 'the platform stores it as JSON, and os generate types called it an array', + ).toBe(`table.jsonb('multi_${type}')`); + }); + } + + it('the flag decides before the type — a type outside MULTI_CAPABLE_TYPES too', () => { + // Stated as its own assertion because it is the one place this pin departs + // from the spec's value predicate on purpose. `text` is not multi-capable + // under `isMultiValueField`, and the driver gives it a JSON column anyway. + expect(MULTI_CAPABLE_TYPES.has('text')).toBe(false); + expect(sqlColumn('multi_text')).toBe('JSONB'); + expect(tsColumn('multi_text')).toBe("table.jsonb('multi_text')"); + }); + + it('nullability still comes from `required`, not from the flag', () => { + const out = generateMigrationSql({ + objects: { probe: { name: 'probe', fields: { tags_req: { type: 'lookup', multiple: true, required: true } } } }, + }); + expect(out).toContain('"tags_req" JSONB NOT NULL'); + const ts = generateMigrationTs({ + objects: { probe: { name: 'probe', fields: { tags_req: { type: 'lookup', multiple: true, required: true } } } }, + }); + expect(ts).toContain("table.jsonb('tags_req').notNullable();"); + }); + + // ── The authority, read where it lives ────────────────────────────────── + // + // Source-read rather than imported: `createColumn` is `protected` and needs a + // knex table builder, so driving it would mean a live driver and a built + // `dist`. What has to be pinned is the SHAPE of its decision — flag first, + // type second — and that is legible in the source. If the driver ever moves + // this rule, these fail and whoever moved it re-derives the generators. + + it('driver-sql `createColumn` still decides `multiple` BEFORE the type switch', () => { + const source = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8'); + // Non-vacuity: the file was really read, and the two landmarks really found. + expect(source.length).toBeGreaterThan(10_000); + const start = source.indexOf('protected createColumn('); + expect(start, 'createColumn moved or was renamed in driver-sql').toBeGreaterThan(0); + const switchAt = source.indexOf('switch (type)', start); + expect(switchAt, 'the per-type switch in createColumn moved').toBeGreaterThan(start); + + const preSwitch = source.slice(start, switchAt); + expect( + preSwitch, + 'driver-sql no longer short-circuits on `field.multiple` before its per-type switch. ' + + 'That short-circuit is the authority this pin and the CLI migration generators mirror ' + + '(#14829) — re-derive both sides before changing it.', + ).toMatch(/if \(field\.multiple\)/); + expect(preSwitch).toMatch(/this\.jsonColumn\(/); + }); + + it('driver-sql `fieldHasColumn` still answers the flag before the type', () => { + const source = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'schema-drift.ts'), 'utf8'); + expect(source.length).toBeGreaterThan(10_000); + const start = source.indexOf('export function fieldHasColumn('); + expect(start, 'fieldHasColumn moved or was renamed in driver-sql').toBeGreaterThan(0); + expect(source.slice(start, start + 300)).toMatch(/if \(field\?\.multiple\) return true;/); + }); + + // ── SCOPE FENCE for #14828 — NOT an endorsement ───────────────────────── + // + // These five scalar answers disagree with what the platform stores and were + // left byte-for-byte on purpose (correcting them changes DDL already-generated + // apps have RUN). #14828 owns them. They are asserted here so that changing + // one is a deliberate edit to this block rather than a side effect of a card + // about the `multiple` flag — #14828 must update it when it corrects them. + it('#14828 fence — the five disputed SCALAR answers are untouched by this card', () => { + expect(sqlColumn('single_lookup')).toBe('VARCHAR(36)'); + expect(tsColumn('single_lookup')).toBe("table.uuid('single_lookup')"); + + const other = generateMigrationSql({ + objects: { probe: { name: 'probe', fields: { + a: { type: 'autonumber' }, f: { type: 'formula' }, + m: { type: 'multiselect' }, v: { type: 'vector' }, d: { type: 'master_detail' }, + } } }, + }); + expect(other).toContain('"a" SERIAL'); + expect(other).toContain('"f" TEXT'); + expect(other).toContain('"m" TEXT'); + expect(other).toContain('"v" VECTOR'); + expect(other).toContain('"d" VARCHAR(36)'); + }); +}); diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index 4afa4d5d0f..3631221bc5 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -564,7 +564,7 @@ function fieldTypeToTs(fieldType: string, multiple?: boolean): string { return multiple ? `${base}[]` : base; } -function generateTypesFromConfig(config: Record): string { +export function generateTypesFromConfig(config: Record): string { const lines: string[] = [ '// Auto-generated by ObjectStack CLI — do not edit manually', `// Generated at ${new Date().toISOString()}`, @@ -1031,7 +1031,7 @@ function fieldTypeToSql(fieldType: string): string { return FIELD_TYPE_SQL_MAP[fieldType] || 'TEXT'; } -function generateMigrationSql(config: Record): string { +export function generateMigrationSql(config: Record): string { const lines: string[] = [ '-- Auto-generated by ObjectStack CLI — do not edit manually', `-- Generated at ${new Date().toISOString()}`, @@ -1078,7 +1078,7 @@ function generateMigrationSql(config: Record): string { return lines.join('\n') + '\n'; } -function generateMigrationTs(config: Record): string { +export function generateMigrationTs(config: Record): string { const lines: string[] = [ '// Auto-generated by ObjectStack CLI — do not edit manually', `// Generated at ${new Date().toISOString()}`, From ba7204962888e968b98bee7b3d47ead13015eb94 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Sep 2026 16:14:19 +0000 Subject: [PATCH 2/2] fix(cli): `multiple: true` takes a JSON column in both migration generators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `os generate types` honoured the flag and neither migration generator did, so one authored `Field.lookup({ multiple: true })` produced an array TS type and a scalar `VARCHAR(36)` / `table.uuid` column from the same config in the same run. The column authority is `driver-sql`, and its answer is the flag alone: `createColumn` short-circuits on `field.multiple` above its own per-type switch, `isJsonField` is `JSON_COLUMN_TYPES.has(type) || !!field.multiple`, and `fieldHasColumn` opens with the same check. Both generators now answer it in the same place — before the type is consulted — so the element type gets no vote. Deliberately NOT the spec's `isMultiValueField`: that is the ADR-0104 D1 value contract, gated on `MULTI_CAPABLE_TYPES`, and it would answer VARCHAR for a `text` field the driver gives a JSON column — the same drift one notch narrower. The per-type vocabularies are untouched; the disputed scalar answers stay byte-for-byte and are pinned as a scope fence. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_016yfqQh2dBgPAymYd7xipza --- ...generate-migration-multiple-json-column.md | 11 +++++ packages/cli/src/commands/generate.ts | 45 +++++++++++++++++-- scripts/cross-package-test-inputs.mjs | 21 +++++++++ turbo.json | 4 +- 4 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 .changeset/generate-migration-multiple-json-column.md diff --git a/.changeset/generate-migration-multiple-json-column.md b/.changeset/generate-migration-multiple-json-column.md new file mode 100644 index 0000000000..8fb0ff8307 --- /dev/null +++ b/.changeset/generate-migration-multiple-json-column.md @@ -0,0 +1,11 @@ +--- +"@objectstack/cli": patch +--- + +`os generate migration` now gives a `multiple: true` field a JSON column, in both formats. One authored field used to produce two incompatible answers from one config in one run: `Field.lookup({ reference: 'account', multiple: true })` emitted `account?: string[]` from `os generate types` and a scalar `VARCHAR(36)` / `table.uuid('account')` column from the two migration generators, because `multiple` appeared exactly four times in `generate.ts` and all four were on the TypeScript side — `fieldTypeToSql` did not even take the parameter. Nothing warned: the scaffold looks right, the generated TypeScript IS right, and only the column is wrong, so the first symptom was a write of an array into a scalar column. That is the `#field-zoo` failure one layer out — there the DDL switch and `isJsonField` had drifted into two lists inside the driver; here the platform and the *generated* DDL were the two lists. + +The authority is the driver's, and it is the flag alone. `SqlDriver.createColumn` short-circuits on `field.multiple` **above** its own `switch (type)`; `isJsonField` is `JSON_COLUMN_TYPES.has(type) || !!field.multiple`; and `fieldHasColumn` opens with `if (field?.multiple) return true` under the comment "Mirrors `SqlDriver.createColumn` exactly … including `multiple` (a JSON column)". Three statements of one rule: a flagged field is a JSON column whatever its element type would have been. Both generators now answer it the same way and in the same place — before the type is consulted at all. + +Deliberately **not** the spec's `isMultiValueField`. That predicate is the ADR-0104 D1 *value* contract ("is the persisted value an array") and gates on `MULTI_CAPABLE_TYPES`, so asking it here would answer `VARCHAR` for a `text` field flagged `multiple: true` while the driver gives that same field a JSON column — the identical drift one notch narrower. `FieldSchema` does not refuse the combination either (`multiple` is a plain `z.boolean()` on every field; only `radio` + `multiple` is refused by name), and the generators sit downstream of validation. The two questions have two different owners: the value shape is the spec's, the column is the driver's. + +Nothing about the existing per-type vocabularies changes. The scalar answers — including the five that are separately disputed — are byte-for-byte what they were, and a new pin asserts that as a scope fence rather than leaving it to a reading of the diff. `generate-multiple-json-column.pin.test.ts` drives all three generators on one config and pins the agreement across every member of the spec's `MULTI_CAPABLE_TYPES` plus a type outside it, so the type-blindness of the rule is an assertion rather than a comment; it also reads the driver's two statements of the rule, so moving them there fails here. diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index 3631221bc5..6cc1e93ac3 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -1027,7 +1027,33 @@ const FIELD_TYPE_SQL_MAP: Record = { address: 'JSONB', } satisfies Record; -function fieldTypeToSql(fieldType: string): string { +/** + * The column one field takes. + * + * `multiple` is answered FIRST, before the type is looked up at all, because + * that is what the platform does. `SqlDriver.createColumn` short-circuits on + * `field.multiple` ABOVE its own `switch (type)`; `isJsonField` is + * `JSON_COLUMN_TYPES.has(type) || !!field.multiple`; and `fieldHasColumn` + * opens with `if (field?.multiple) return true` under the comment "Mirrors + * `SqlDriver.createColumn` exactly ... including `multiple` (a JSON column)". + * Three statements of one rule: a flagged field is a JSON column whatever its + * element type would have been, so the element type gets no vote here either + * (#14829). Before this, one authored `Field.lookup({ multiple: true })` + * produced `account?: string[]` from `os generate types` and a scalar + * `VARCHAR(36)` column from this generator, in the same run. + * + * WARNING: this is deliberately NOT the spec's `isMultiValueField`. That is the + * ADR-0104 D1 VALUE contract ("is the persisted value an array"), gated on + * `MULTI_CAPABLE_TYPES`; asking it here would answer VARCHAR for a `text` + * field the driver gives a JSON column - the same drift one notch narrower. + * The column question belongs to the driver, and the driver's answer is the + * flag alone. `generate-multiple-json-column.pin.test.ts` pins both halves. + * + * The JSON spelling is READ from this table's own `json` entry rather than + * restated, so the two cannot drift about what a JSON column is spelled here. + */ +function fieldTypeToSql(fieldType: string, multiple?: boolean): string { + if (multiple) return FIELD_TYPE_SQL_MAP.json; return FIELD_TYPE_SQL_MAP[fieldType] || 'TEXT'; } @@ -1063,7 +1089,7 @@ export function generateMigrationSql(config: Record): string { const fieldLines: string[] = []; for (const [fieldName, fieldDef] of Object.entries(fields)) { - const sqlType = fieldTypeToSql(String(fieldDef.type || 'text')); + const sqlType = fieldTypeToSql(String(fieldDef.type || 'text'), !!fieldDef.multiple); const notNull = fieldDef.required ? ' NOT NULL' : ''; fieldLines.push(` "${fieldName}" ${sqlType}${notNull}`); } @@ -1117,8 +1143,21 @@ export function generateMigrationTs(config: Record): string { for (const [fieldName, fieldDef] of Object.entries(fields)) { const fType = String(fieldDef.type || 'text'); const required = fieldDef.required ? '.notNullable()' : '.nullable()'; - let colMethod: string; + // #14829 - `multiple` before the type, exactly as `SqlDriver.createColumn` + // does it: the driver short-circuits on the flag above its own per-type + // switch, so a flagged field is a JSON column whatever its element type + // would have been. Emitted here rather than as a switch arm because the + // switch cases on the TYPE and the type has no vote in this decision; + // the spelling is this generator's own JSON arm, stated once more. + // See `fieldTypeToSql` for why the authority is the driver's flag rule + // and not the spec's `isMultiValueField` value predicate. + if (fieldDef.multiple) { + lines.push(` table.jsonb('${fieldName}')${required};`); + continue; + } + + let colMethod: string; switch (fType) { case 'text': case 'email': case 'phone': case 'url': case 'select': case 'password': case 'color': diff --git a/scripts/cross-package-test-inputs.mjs b/scripts/cross-package-test-inputs.mjs index 4efb8bfbbb..110ecda2e3 100644 --- a/scripts/cross-package-test-inputs.mjs +++ b/scripts/cross-package-test-inputs.mjs @@ -391,6 +391,27 @@ export const CROSS_PACKAGE_TEST_INPUTS = { // One file, not `packages/create-objectstack/**`: the test reads that // template and nothing else across the boundary. 'packages/create-objectstack/src/templates/blank/pnpm-workspace.yaml', + // The two files that hold the COLUMN authority the CLI's migration + // generators mirror, READ by + // src/commands/generate-multiple-json-column.pin.test.ts (#14829). That + // pin asserts a `multiple: true` field gets a JSON column from both + // `os generate migration` formats because `SqlDriver.createColumn` + // short-circuits on the flag ABOVE its per-type switch, and + // `fieldHasColumn` mirrors that decision for the drift differ. Source-read + // rather than imported: `createColumn` is `protected` and needs a knex + // table builder, so driving it would mean a live driver and a built + // `dist`, while the SHAPE of its decision — flag first, type second — is + // exactly what has to stay true and is legible in the source. + // + // The declaration is the whole point of the pin, not paperwork around it: + // if the driver moves that rule and cli's suite does not re-run, the two + // sides drift again in silence, which is the #14829 defect returning by + // the cache. Two files rather than `packages/drivers/driver-sql/src/**`: + // the pin reads these two and nothing else across the boundary, and that + // package's `src` is edited often enough that the subtree glob would put + // cli's whole suite on every driver commit. + 'packages/drivers/driver-sql/src/sql-driver.ts', + 'packages/drivers/driver-sql/src/schema-drift.ts', ], }, '@objectstack/client': { diff --git a/turbo.json b/turbo.json index 06cae481f2..ff4197c601 100644 --- a/turbo.json +++ b/turbo.json @@ -107,7 +107,9 @@ "$TURBO_ROOT$/scripts/cross-package-test-inputs.mjs", "$TURBO_ROOT$/packages/spec/src/system/translation.zod.ts", "$TURBO_ROOT$/scripts/check-cross-package-test-inputs.mjs", - "$TURBO_ROOT$/packages/create-objectstack/src/templates/blank/pnpm-workspace.yaml" + "$TURBO_ROOT$/packages/create-objectstack/src/templates/blank/pnpm-workspace.yaml", + "$TURBO_ROOT$/packages/drivers/driver-sql/src/sql-driver.ts", + "$TURBO_ROOT$/packages/drivers/driver-sql/src/schema-drift.ts" ] }, "@objectstack/client#test": {