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
Expected: composite foreign keys and single column foreign are working consistently.
Actual: No resource embedding happens across join tables when the are composite keys in the join table.
Steps to reproduce:
CREATE SCHEMA api;
CREATE TABLE IF NOT EXISTS api.test_a(
id1 int NOT NULL,
id2 int NOT NULL,
a VARCHAR(64) NOT NULL,
PRIMARY KEY (id1, id2)
);
CREATE TABLE IF NOT EXISTS api.test_b(
id1 int NOT NULL,
id2 int NOT NULL,
b VARCHAR(64) NOT NULL,
PRIMARY KEY (id1, id2)
);
CREATE TABLE IF NOT EXISTS api.test_lnk (
a1 INT NOT NULL,
a2 INT NOT NULL,
b1 INT NOT NULL,
b2 INT NOT NULL,
CONSTRAINT fk_test_a
FOREIGN KEY (a1,a2)
REFERENCES api.test_a(id1,id2),
CONSTRAINT fk_test_b
FOREIGN KEY (b1,b2)
REFERENCES api.test_b(id1,id2)
) ;
curl 'http://localhost:3000/test_a?select=test_b(*)'
{"message":"Could not find foreign keys between these entities. No relationship found between test_a and test_b"}
However all of the following is working as expected:
Missing composite keys are pretty much showstopper for my project, therefore I've scanned the source and added a pull request #1593 to fix this issue. All tests are fine, and it seems to be working. Somebody more familiar with the project may comment why was it restricted in the first place.
Environment
Description of issue
Expected: composite foreign keys and single column foreign are working consistently.
Actual: No resource embedding happens across join tables when the are composite keys in the join table.
Steps to reproduce:
In postgrest.conf:
Running the resource embedding query fails:
However all of the following is working as expected:
Therefore it seems one level of resource embedding is working fine, but any indirect embedding fails.
If I change the primary keys and constraint from composite to single valued keys, everything works as expected.
The text was updated successfully, but these errors were encountered: