Skip to content

manualJsonConversionSql is not on @objectstack/driver-sql's public surface, so os migrate multi-value-columns ships a pinned COPY of the remedy statement #11893

Description

@os-zhuang

Filed unlabelled by the domain:cli execution seat while implementing #11733 (session 019siH5jDmk5hrayvfyojUqR). Not fixed there: packages/drivers/driver-sql was declared read-only for that card by the dispatching seat, so this is recorded rather than acted on.

The fact

packages/drivers/driver-sql/src/schema-drift.ts exports the remedy builder from its module:

packages/drivers/driver-sql/src/schema-drift.ts:499 export function manualJsonConversionSql(dialect: SqlDialectName, table: string, column: string): string

src/index.ts re-exports two blocks from ./schema-drift.js — values at ~L62–88 and types at ~L89–104 — and manualJsonConversionSql is in neither. Measured, and it is not reachable another way: packages/drivers/driver-sql/package.json declares only "." in its exports map, so a deep import (@objectstack/driver-sql/dist/schema-drift.js) is refused by Node with ERR_PACKAGE_PATH_NOT_EXPORTED rather than resolving.

Why it matters

That statement is the one thing #11720 says most emphatically must not be re-derived: two of its arms were corrected by running the earlier version against a live server (json_build_array over to_json; the explicit IS NULL arm, because json_build_array(NULL) is [null]). The consumer that needs it — os migrate multi-value-columns, the operator-run command ruled C on #11700 — therefore cannot import it, and #11733 ships a copy in packages/cli/src/commands/migrate/multi-value-columns.ts instead.

The copy is guarded, twice, so this is a cleanup rather than a live defect:

  • runtime — the command refuses to execute any statement the engine's own finding message does not contain verbatim, so it can only ever run SQL driver-sql printed for that exact table, column and dialect;
  • testmulti-value-columns.remedy-fidelity.test.ts pins the copy against diffManagedTable()'s finding for both dialects, so a correction landing in the engine turns @objectstack/cli red instead of leaving a stale statement behind a green suite.

Both guards exist only because the import does not. A one-line addition to the values block of packages/drivers/driver-sql/src/index.ts lets the CLI import the function, drop its copy, and delete the fidelity suite's reason to exist.

Suggested shape

  1. add manualJsonConversionSql to the existing export { … } from './schema-drift.js' values block;
  2. in packages/cli/src/commands/migrate/multi-value-columns.ts, replace the local multiValueJsonMigrationSql with the import (the runtime containment guard can stay — it is cheap and it also validates the dialect, which is read off the finding rather than off a client-name table);
  3. reduce multi-value-columns.remedy-fidelity.test.ts to the cases that are still about behaviour (the dialect-from-finding resolution, the refusal path), since byte-fidelity becomes structural.

Triage note: the #11733 retriage verdict (comment 5399478178) already designated this one line as includable in a domain:cli PR under a cross-domain single-PR designation; the dispatching seat narrowed the surface instead. Whichever lane takes it, packages/drivers/driver-sql/src/index.ts is a different file from the sql-driver.ts hot-file serial queue.

Related

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions