Commit 95437e7
* fix(driver-sql): emit the spec `primaryKey` column spelling, not `isPrimary` (#10676)
`SqlDriver.introspectSchema` declared its own `IntrospectedColumn` and spelled
primary-key membership `isPrimary`, while everything downstream of `plugin.ts`
is typed against `packages/spec/src/contracts/schema-diff-service.ts`, which
spells it `primaryKey`. The value crossed between the two contracts untyped, so
`ExternalDatasourceService.generateObjectDraft` — which reads `col.primaryKey`
— saw `undefined` on every real driver result and every federated object
drafted from a remote table silently lost its remote primary key.
Maintainer ruling, 2026-08-22 (live session, 「同意所有」 item 9 =
驱动侧对齐 spec 契约): `packages/spec` is the one contract and the driver
aligns to it.
- `driver-sql` and `objectql/src/util.ts` now DERIVE `IntrospectedColumn` from
the spec import instead of re-declaring it, so a key added to the contract
fails their `tsc` until the producer emits it. Two divergences are kept
explicitly (`defaultValue` stays `unknown` — Knex reports `null`; `isUnique`
/ `maxLength` are SQL extras the spec does not declare).
- The driver emits `primaryKey` and no longer emits `isPrimary`: one spelling,
so no consumer can key off the wrong one again.
- New pin `external-object-draft-real-introspection.test.ts` drives
`generateObjectDraft` off a REAL `introspectSchema()` result, which is what
the ruling requires and what the hand-written fixtures could never do. It
fails on the pre-fix driver (measured: the `// Remote primary key:` line is
absent) and asserts the key does not return as the unauthorable
`fields.<f>.primaryKey`.
- `external-introspection-seam.test.ts` asserted the producer's OLD spelling as
a deliberate landmine; its producer-spelling case is flipped to the new
direction. The service's three-signal union read is untouched.
Fixes #10676
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RfyXxZ2WPjcjhuXpiQQc3y
* fix(driver-sql): emit the spec `dialect` and required `introspectedAt` (#10998)
`introspectSchema()` returned `{ tables }` and nothing else, while
`packages/spec/src/contracts/schema-diff-service.ts` declares `dialect` and a
REQUIRED `introspectedAt`. Measured live on in-memory SQLite before this
change: `Object.keys()` was `["tables"]`. Two silent consequences — type
mapping ran with `dialect: undefined` on the whole federation path, so every
per-dialect alias in `suggestFieldTypeForSqlType` was unreachable there, and
`refreshCatalog` persisted `dialect: undefined` into the `external_catalog`
record Studio's schema browser and the boot gate read back.
Same ruling as #10676 (2026-08-22, 「同意所有」 item 9): the driver aligns to
the one contract.
- `IntrospectedTable` / `IntrospectedSchema` now derive from the spec import in
both `driver-sql` and `objectql/src/util.ts`, so `introspectedAt` being
required is enforced by `tsc` rather than by remembering. `indexes` is
`Omit`ted rather than emitted empty: this driver does not introspect indexes,
and `[]` would claim a table has none — filed separately, not guessed.
- `dialect` is `this.dialectName` (`sqlite` / `postgres` / `mysql` /
`unknown`), NOT the raw Knex client and NOT the spec's `SQLDialectSchema`
enum: the only in-tree consumer keys `DIALECT_ALIASES` on the `SqlDialect`
vocabulary of `type-compat.ts`, which spells PostgreSQL `postgres`. Emitting
`postgresql` would satisfy `Object.keys()` while leaving the aliases just as
unreachable.
- `introspectedAt` is stamped before the reads begin, so it never claims to
cover a moment later than the first table actually read.
Measured after: `Object.keys()` is `["tables","dialect","introspectedAt"]`;
the persisted catalog records `dialect: 'sqlite'`. On the SQLite arm the
suggested field types are byte-identical before and after (its alias map
overlaps the base map); the per-dialect payoff is on Postgres/MySQL, which are
unreachable from this container and are therefore not claimed.
Fixes #10998
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RfyXxZ2WPjcjhuXpiQQc3y
* chore(changeset): driver-sql emits the spec introspection contract (#10676, #10998)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RfyXxZ2WPjcjhuXpiQQc3y
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent d806081 commit 95437e7
8 files changed
Lines changed: 515 additions & 68 deletions
File tree
- .changeset
- packages
- drivers/driver-sql/src
- objectql/src
- services/service-datasource/src/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
| 98 | + | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
Lines changed: 105 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
11 | 19 | | |
12 | 20 | | |
13 | 21 | | |
| |||
3645 | 3653 | | |
3646 | 3654 | | |
3647 | 3655 | | |
3648 | | - | |
3649 | | - | |
3650 | | - | |
3651 | | - | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
3652 | 3689 | | |
3653 | | - | |
| 3690 | + | |
3654 | 3691 | | |
| 3692 | + | |
3655 | 3693 | | |
3656 | 3694 | | |
3657 | 3695 | | |
| 3696 | + | |
3658 | 3697 | | |
3659 | 3698 | | |
3660 | 3699 | | |
3661 | 3700 | | |
3662 | 3701 | | |
3663 | 3702 | | |
3664 | 3703 | | |
3665 | | - | |
3666 | | - | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
3667 | 3712 | | |
| 3713 | + | |
3668 | 3714 | | |
| 3715 | + | |
3669 | 3716 | | |
3670 | 3717 | | |
3671 | 3718 | | |
3672 | | - | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
3673 | 3726 | | |
3674 | 3727 | | |
3675 | 3728 | | |
| |||
9798 | 9851 | | |
9799 | 9852 | | |
9800 | 9853 | | |
| 9854 | + | |
| 9855 | + | |
| 9856 | + | |
| 9857 | + | |
9801 | 9858 | | |
9802 | 9859 | | |
9803 | 9860 | | |
| |||
9837 | 9894 | | |
9838 | 9895 | | |
9839 | 9896 | | |
9840 | | - | |
| 9897 | + | |
9841 | 9898 | | |
9842 | 9899 | | |
9843 | 9900 | | |
9844 | 9901 | | |
9845 | 9902 | | |
9846 | 9903 | | |
9847 | | - | |
| 9904 | + | |
| 9905 | + | |
| 9906 | + | |
| 9907 | + | |
| 9908 | + | |
| 9909 | + | |
| 9910 | + | |
| 9911 | + | |
| 9912 | + | |
9848 | 9913 | | |
9849 | 9914 | | |
9850 | 9915 | | |
| |||
12548 | 12613 | | |
12549 | 12614 | | |
12550 | 12615 | | |
12551 | | - | |
| 12616 | + | |
| 12617 | + | |
| 12618 | + | |
12552 | 12619 | | |
12553 | 12620 | | |
12554 | 12621 | | |
| |||
12695 | 12762 | | |
12696 | 12763 | | |
12697 | 12764 | | |
12698 | | - | |
| 12765 | + | |
12699 | 12766 | | |
12700 | 12767 | | |
12701 | 12768 | | |
| |||
0 commit comments