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
Describe the bug
When I have a table that has a foreign key reference, and then I create a unique partial index on the same field, the
To Reproduce
I have a table called "works" and a table called "readthroughs". Each work can have many readthroughs. I want to ensure there is at most one in progress readthrough per work at a given time.
Create tables and insert the initial values:
CREATE TABLE IF NOT EXISTS public.works (
work_id INTEGER,
PRIMARY KEY (work_id)
);
CREATE TABLE IF NOT EXISTS public.readthroughs (
readthrough_id INTEGER NOT NULL,
work_id INTEGER NOT NULL,
status TEXT NOT NULL,
PRIMARY KEY (readthrough_id),
FOREIGN KEY (work_id) REFERENCES public.works (work_id) ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO public.works (work_id) VALUES (1);
INSERT INTO public.readthroughs (readthrough_id, work_id, status)
VALUES (1, 1, 'in_progress');
COMMENT ON TABLE public.readthroughs IS E'@graphql({"totalCount": {"enabled": true}})';
CREATE UNIQUE INDEX idx_unique_active_readthrough ON public.readthroughs (work_id)
WHERE status IN ('in_progress');
The GraphiQL docs now look like this:
And I can no longer use readthroughsCollection in my GraphQL queries.
This feels like it might be related to #541 and #502, i.e. pg_graphql generating readthroughCollection based on the foreign key but then overwriting it because of the index.
Expected behavior
Creating a unique partial index shouldn't screw with existing Collections
The text was updated successfully, but these errors were encountered:
Describe the bug
When I have a table that has a foreign key reference, and then I create a unique partial index on the same field, the
To Reproduce
I have a table called "works" and a table called "readthroughs". Each work can have many readthroughs. I want to ensure there is at most one in progress readthrough per work at a given time.
Create tables and insert the initial values:
When I look at the GraphiQL docs, I see:

I can run queries like this successfully:
Now I add a unique partial index:
The GraphiQL docs now look like this:

And I can no longer use readthroughsCollection in my GraphQL queries.
This feels like it might be related to #541 and #502, i.e. pg_graphql generating readthroughCollection based on the foreign key but then overwriting it because of the index.
Expected behavior
Creating a unique partial index shouldn't screw with existing Collections
The text was updated successfully, but these errors were encountered: