Skip to content

fix issue #511 #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ impl FunctionBuilder {
from
{from_clause} as {func_block_name}
where
{func_block_name} is not null
not ({func_block_name} is null)
)
"
)
Expand Down
88 changes: 88 additions & 0 deletions test/expected/issue_511.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
begin;
create table users(
id uuid primary key,
email character varying (255),
phone text
);
insert into public.users(id, email, phone)
values
('dd5add8a-7dd2-4495-bc1a-a1dfe95ef23a', '[email protected]', '987654321'),
('12e684cc-b7c2-492e-8554-9ab3e03fa37f', null, null),
('748a81bb-5f71-4dc8-88d9-efe9f03a14b8', null, '123456789');
create or replace view users_with_phone as select
id,
email,
phone
from public.users
where phone is not null;
create table polls(
id uuid primary key,
user_id uuid references users(id)
);
insert into public.polls(id, user_id)
values
('98813159-4814-42fa-911d-5cc900bd80b8', 'dd5add8a-7dd2-4495-bc1a-a1dfe95ef23a'),
('07dc0104-3811-4a5d-8887-4018c8116e5c', '12e684cc-b7c2-492e-8554-9ab3e03fa37f'),
('3bec2818-7bea-40ba-81fa-7d0ba061c3de', '748a81bb-5f71-4dc8-88d9-efe9f03a14b8');
create
or replace function author (rec polls) returns users_with_phone stable strict language sql security definer
set
search_path = public as $$
select
*
from users_with_phone u
where u.id = $1.user_id;
$$;
select jsonb_pretty(
graphql.resolve($$
{
pollsCollection {
edges {
node {
author {
id,
email,
phone
}
}
}
}
}
$$)
);
jsonb_pretty
---------------------------------------------------------------------------
{ +
"data": { +
"pollsCollection": { +
"edges": [ +
{ +
"node": { +
"author": null +
} +
}, +
{ +
"node": { +
"author": { +
"id": "748a81bb-5f71-4dc8-88d9-efe9f03a14b8",+
"email": null, +
"phone": "123456789" +
} +
} +
}, +
{ +
"node": { +
"author": { +
"id": "dd5add8a-7dd2-4495-bc1a-a1dfe95ef23a",+
"email": "[email protected]", +
"phone": "987654321" +
} +
} +
} +
] +
} +
} +
}
(1 row)

rollback;
61 changes: 61 additions & 0 deletions test/sql/issue_511.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
begin;

create table users(
id uuid primary key,
email character varying (255),
phone text
);

insert into public.users(id, email, phone)
values
('dd5add8a-7dd2-4495-bc1a-a1dfe95ef23a', '[email protected]', '987654321'),
('12e684cc-b7c2-492e-8554-9ab3e03fa37f', null, null),
('748a81bb-5f71-4dc8-88d9-efe9f03a14b8', null, '123456789');

create or replace view users_with_phone as select
id,
email,
phone
from public.users
where phone is not null;

create table polls(
id uuid primary key,
user_id uuid references users(id)
);

insert into public.polls(id, user_id)
values
('98813159-4814-42fa-911d-5cc900bd80b8', 'dd5add8a-7dd2-4495-bc1a-a1dfe95ef23a'),
('07dc0104-3811-4a5d-8887-4018c8116e5c', '12e684cc-b7c2-492e-8554-9ab3e03fa37f'),
('3bec2818-7bea-40ba-81fa-7d0ba061c3de', '748a81bb-5f71-4dc8-88d9-efe9f03a14b8');

create
or replace function author (rec polls) returns users_with_phone stable strict language sql security definer
set
search_path = public as $$
select
*
from users_with_phone u
where u.id = $1.user_id;
$$;

select jsonb_pretty(
graphql.resolve($$
{
pollsCollection {
edges {
node {
author {
id,
email,
phone
}
}
}
}
}
$$)
);

rollback;
Loading