fix(selfhost): translate json_each() array iteration for Postgres - #9383
Merged
Conversation
migrations/0191_linked_issue_claims.sql's backfill uses SQLite's
json_each(text) to iterate a JSON array column. Untranslated on the
self-host Postgres backend, Postgres's own json_each() only accepts
JSON objects and rejects a text argument outright
("function json_each(text) does not exist"), crash-looping the
migration runner on boot and taking self-host Postgres deployments
down. Add a json_each -> json_array_elements_text translation rule,
verified against a real Postgres 16 running the full migration chain.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
loopover-ui | a633f4a | Jul 27 2026, 03:31 PM |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9383 +/- ##
==========================================
- Coverage 89.46% 88.56% -0.91%
==========================================
Files 836 836
Lines 109590 109591 +1
Branches 26098 26098
==========================================
- Hits 98048 97058 -990
- Misses 10279 11561 +1282
+ Partials 1263 972 -291
Flags with carried forward coverage won't be shown. Click here to find out more.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
json_each(text), which reaches Postgres untranslated (Postgres's ownjson_each()only accepts JSON objects, so it throwsfunction json_each(text) does not exist).json_each(col) alias->json_array_elements_text((col)::json) AS alias(value)translation rule inpg-dialect.ts, matching the existingjson_extracttranslation pattern.runSelfHostMigrationsend-to-end, and confirmed the backfill produces correct rows from a JSON array ([7,42]-> twolinked_issue_claimsrows).Test plan
test/unit/selfhost-pg-dialect.test.tscovering both the bare-alias andAS-alias forms, plus the full migration statementnpm run typecheckcleantest/unitsweep: 766 passed, 0 failures related to this change