You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(stack): select('*') must alias renamed v3 columns back to their property
`select('*')` expanded the introspected column list, which holds DB column
names. `addJsonbCastsV3` only emits the `prop:db_name::jsonb` PostgREST alias
when it sees a *property* name; a raw DB name took the unaliased
`dbNames.has(...)` branch. So on a declared table with a property→DB rename,
rows came back keyed `created_at` while the declared row type promises
`createdAt` — `row.createdAt` was silently `undefined` for a field TypeScript
guaranteed as a Date. Synthesized columns were unaffected (property == DB name),
which is why no existing test caught it: the select-star suite used only
matching names, and the rename suite used only explicit selects.
Adds an `expandAllColumns` hook on the base builder (identity for v2, which
never supplies a column list) that the v3 dialect overrides to map DB names
back through the inverse of `buildColumnKeyMap()`.
Also fixes a pre-existing prototype-inheritance hazard surfaced by the new
tests: `propToDb` was a plain object indexed by column names that originate in
the database, so a plaintext column named `constructor` resolved to
`Object.prototype.constructor` — truthy — and interpolated
`function Object() { [native code] }` into the emitted select string. It was
reachable from explicit selects too (`select('constructor')`), and equally from
`filterColumnName` and the mutation-payload transform. `buildColumnKeyMap()` now
returns a null-prototype map, and every read site is `Object.hasOwn`-guarded —
the same belt-and-braces the DOMAIN_REGISTRY already uses.
Regression tests assert the resulting ROW KEY, not just the select string: the
Supabase double now simulates PostgREST's alias projection, since the alias is
what performs the rename server-side. All five new assertions fail against the
prior implementation.
0 commit comments