Skip to content

9 fixtures across 6 packages declare reference_to on a lookup — a key FieldSchema refuses — and the SQL driver's FK-emission branch has no test at all #12252

Description

@os-warren

Found while measuring #11567. Filed unassigned. Pre-existing.

What

reference is the only relationship spelling FieldSchema declares. reference_to is a rejected alias — measured on origin/main:

FieldSchema.safeParse({ name:'parent', type:'lookup', reference_to:'p' })
=> success: false, issue.code = unrecognized_keys, keys = ["reference_to"]

Nine test fixtures nevertheless declare it, so each describes an object no author could publish:

fileline
packages/objectql/src/engine-multivalue-normalize.test.ts36
packages/rest/src/meta-object-materialization-agreement.test.ts126
packages/rest/src/meta-object-search-companion-agreement.test.ts99
packages/runtime/src/batch-row-http-status-real-driver.integration.test.ts64
packages/runtime/src/batch-row-driver-text-real-driver.integration.test.ts59
packages/lint/src/validate-flow-template-paths.test.ts21, 22
packages/lint/src/runtime-lazy-deps.test.ts120
packages/drivers/driver-sql/src/sql-driver-schema.test.ts122

(packages/spec/src/shared/suggestions.test.ts, packages/spec/src/ui/action.test.ts and packages/lint/src/validate-security-posture.test.ts also name the string, but those are asserting the rejection — they are correct and are not in this list.)

registerObject deliberately skips Zod ("the ones that skip Zod and lint (#3896, raw registerObject)", packages/objectql/src/registry.ts), which is why these fixtures run at all.

Why it matters — this is not only tidiness

These fixtures exercise driver branches that authored metadata never reaches, and one of them is measurably load-bearing for a wrong conclusion. #11567 was filed on a live-MySQL observation that a lookup column "produces a real CONSTRAINT … FOREIGN KEY whenever the field carries reference_to". That reading is true — and irrelevant to production, because the only things that carry reference_to are fixtures like these. The investigation had to run a full live measurement on Postgres 16.13 + MySQL 8.0.46 to establish that an ordinary authored lookup gets no FK.

Per sql-driver-schema.test.ts:122 the reference_to is incidental (the case is about multiple: true producing a JSON column), so most of these are a one-word fixture correction. Two of them (packages/rest, agreement suites) describe objects served over /meta, where a spec-invalid shape is a more interesting question.

The related hole

Repo-wide there is no test that asserts whether a lookup field does or does not get a FOREIGN KEY. Every FK-touching driver test (sql-driver-introspection.test.ts:102/149, sql-driver-11201-introspect-fk-schema-scope.test.ts, sql-driver-11324-*, sqlite-wasm-driver-introspection.test.ts:98/145) creates its FKs with raw knex DDL and then introspects them — none goes through createColumn. So the FK-emission branch at sql-driver.ts:13994-13995 has zero coverage of its own output, in either direction. Whatever #11567 is ruled to be, a pin belongs on the outcome.

Suggested disposition

Correct the nine fixtures to reference, and add one pin at the driver layer asserting the ruled FK behaviour for an authored lookup. ⚠️ Correcting the spelling may change what some of these suites observe (that is the point) — each needs re-judging individually rather than a batch rename.


Generated by Claude Code

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions