Skip to content

fix(postgrest-typegen): order generated output with a fixed collation - #181

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/postgrest-typegen-explicit-collation
Sep 15, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/postgrest-typegen-explicit-collation

Conversation

@spydon

@spydon spydon commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Stacked on #180 (which is stacked on #179).

Summary

sortGeneratorMetadata, the TypeScript generator's merge sorts and the Swift generator's sorts all used String.prototype.localeCompare without a locale, so the canonical order of generated output depended on the default locale of the machine running the generator.

Reproduction with Node 26:

LANG=en_US.UTF-8 node -e '...["b","ä","a","z"].sort((a,b)=>a.localeCompare(b))'   # ["a","ä","b","z"]
LANG=sv_SE.UTF-8 node -e '...'                                                      # ["a","b","z","ä"]

Bun currently ignores the host locale and always resolves en-US, so the CLI binary is not affected today, but postgres-meta and any Node consumer are, and nothing pins the behaviour.

All 24 comparisons now go through a single Intl.Collator("en") in src/collation.ts. English has no tailoring over the ICU root collation, so this is exactly the order the English CI runners and the postgres-meta parity fixtures already produce; only machines with another default locale change, and they now agree with CI.

Verification

  • New test in sort.test.ts asserting ["a", "ä", "b", "z"] regardless of host locale.
  • bun run test with Docker: 134 pass. No snapshot or parity fixture changed, which is the point.
  • check-types, format-and-lint and knip pass.

@spydon
spydon requested a review from a team as a code owner September 14, 2026 15:42
@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: d569d106-4ac0-4797-a374-be942e7d2b64


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@spydon
spydon added this pull request to stack #182 September 14, 2026 15:56
@spydon
spydon force-pushed the lukasklingsbo/postgrest-typegen-explicit-collation branch from b4f122d to 0472baf Compare September 14, 2026 15:59
@spydon
spydon force-pushed the lukasklingsbo/postgrest-typegen-explicit-collation branch from 0472baf to ba0dcf3 Compare September 15, 2026 08:55
Base automatically changed from lukasklingsbo/postgrest-typegen-introspection-cleanup to main September 15, 2026 08:56
Every ordering in the package used String.prototype.localeCompare without
a locale, which follows the host's default locale. Under Node a Swedish
locale sorts a table named ä after z while an English one sorts it next to
a, so the same database produced differently ordered output on differently
configured machines. All comparisons now go through one Intl.Collator
pinned to English, which is the order the English CI runners and the
postgres-meta parity fixtures already have.
@spydon
spydon force-pushed the lukasklingsbo/postgrest-typegen-explicit-collation branch from ba0dcf3 to c06ecac Compare September 15, 2026 08:56
@spydon
spydon merged commit af7f8e8 into main Sep 15, 2026
5 checks passed
@spydon
spydon deleted the lukasklingsbo/postgrest-typegen-explicit-collation branch September 15, 2026 08:56
spydon pushed a commit that referenced this pull request Sep 15, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.2.2](postgrest-typegen-v0.2.1...postgrest-typegen-v0.2.2)
(2026-09-15)


### Bug Fixes

* **postgrest-typegen:** order generated output with a fixed collation
([#181](#181))
([af7f8e8](af7f8e8))
* **postgrest-typegen:** resolve composite args on foreign tables and
matviews ([#143](#143))
([e422eb7](e422eb7))
* **postgrest-typegen:** update-only trigger views, PG18 virtual
generated columns, legacy metadata compatibility
([#128](#128))
([50661bd](50661bd))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
spydon added a commit that referenced this pull request Sep 16, 2026
…eta (#192)

## Why

The scheduled "Parity vs. real postgres-meta" job in
`postgrest-typegen-validate.yml` has failed every night since 2026-09-10
(SDK-1847). The ticket assumed postgres-meta had changed its Python
template after the cutover. It is the other way around: postgres-meta
deleted its templates in
supabase/postgres-meta#1084 (postgres-meta
v0.99.0, 2026-08-31) and now consumes `@supabase/postgrest-typegen`,
with its lockfile pinned to `0.2.0`.

The job therefore diffs `main` against our own `0.2.0` release as
installed by postgres-meta's `npm ci`. Every intentional generator
change since then shows up as "drift":

- Python `JsonValue`, `typing_extensions` imports, and `Optional[...]`
composite attributes (#124, released in 0.2.1). In the diff, the `-`
lines are postgres-meta's output and the `+` lines are ours.
- TypeScript fixed-collation ordering (#181, released in 0.2.2), which
started failing today's run as well.

There is no independent upstream left to compare against. Comparing
against postgres-meta only measures how far behind its pinned version
is, and postgres-meta's own snapshot tests cover its adapter.

## What

- Remove the `parity-check` job and the `schedule` and
`workflow_dispatch` triggers that only existed for it; the remaining
`test` job runs on push and pull requests as before.
- Delete `scripts/load-fixtures.ts`, `scripts/print-generated.ts`, and
`scripts/canonicalize-typescript.ts`, which only served that job, and
drop their knip entries.
- Replace the "Byte-Parity Constraint" section in the package
`CLAUDE.md` with a description of the post-cutover relationship (this
package is the single source of truth; output changes are behavior
changes for postgres-meta and the CLI, reviewed via the regenerated
snapshots and goldens). Adjust the README and the golden test's doc
comment to match. The `prettier` pin note was already stale since the
package has no prettier dependency.

The golden test under `test/parity/` and its `expected/` files stay as
the in-repo regression gate.

## Verification

`bun run check-types`, `bun run format-and-lint`, `bun run knip`, and
`bun run test` (134 tests, including the testcontainers-backed golden
test) pass locally.

Closes SDK-1847.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants