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>
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