Skip to content

Commit

Permalink
fix: Embed One-to-One relationship with different column order properly
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangwalther committed Jul 13, 2024
1 parent e642086 commit 5359382
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- #3091, Broken link in OpenAPI description `externalDocs` - @salim-b
- #3659, Embed One-to-One relationship with different column order properly - @wolfgangwalther

## [12.2.2] - 2024-07-10

Expand Down
2 changes: 1 addition & 1 deletion src/PostgREST/SchemaCache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ allM2OandO2ORels pgVer =
JOIN LATERAL (
SELECT
array_agg(row(cols.attname, refs.attname) order by ord) AS cols_and_fcols,
jsonb_agg(cols.attname order by ord) AS cols
jsonb_agg(cols.attname order by cols.attnum) AS cols
FROM unnest(traint.conkey, traint.confkey) WITH ORDINALITY AS _(col, ref, ord)
JOIN pg_attribute cols ON cols.attrelid = traint.conrelid AND cols.attnum = col
JOIN pg_attribute refs ON refs.attrelid = traint.confrelid AND refs.attnum = ref
Expand Down
2 changes: 1 addition & 1 deletion test/spec/fixtures/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,7 @@ CREATE TABLE test.students_info(
, code text
, address text
, primary key(id, code)
, foreign key (id, code) references test.students(id, code) on delete cascade
, foreign key (code, id) references test.students(code, id) on delete cascade
);

CREATE TABLE test.country(
Expand Down

0 comments on commit 5359382

Please sign in to comment.