Closed allezxandre closed 1 year ago
This might be related to pgadmin
, but I see the issue has been solved upstream here: https://github.com/pgadmin-org/pgadmin4/issues/4785
Thank you for reporting this issue. This is likely a problem with statement splitter https://github.com/supabase/cli/blob/main/internal/utils/parser/state.go not dealing with semicolons properly in begin atomic functions.
We will look into it more in due course and address them.
Hi, I just encountered this issue with the CREATE RULE
statement which also contains semicolons as part of the statement (but enclosed in parenthesis).
I can verify using the debug flag that the statement is split incorrectly.
Technically, you can work around it by putting the statement inside a dynamic sql EXECUTE
in a plpgsql DO
block. This is however hilariously too complicated 😂
I guess the issue is exactly here, in SplitAndTrim function.
The workaround using dynamic SQL is a big no for me. Any progress here?
Thanks in advance
Thanks for bumping this issue. I've pushed my changes to a draft PR. Will circle back again early next week.
@sweatybridge , I'm still seeing issues with begin atomic. I think related to case expressions, perhaps due to the 'end' statement of case expressions.
Failing:
create
or replace function public."queryPublishedStories" ("queryOrder" jsonb) returns setof "apiStory" language sql
begin atomic
select
*
from
"apiStory" s
order by
case "queryOrder" ->> 'runtimeType'
when 'DatePublished' then s."datePublished"
end;
end;
Bug report
Describe the bug
It is not possible to create a procedure or function using the
BEGIN ATOMIC
syntax from PostgreSQL 14 in a Supabase migration.Probably a side-effect, but running
supabase db diff
after such a function has been defined returns:supabase db diff --use-migra
does not have the issue:To Reproduce
Create a new migration (
supabase migration new function-test
), and add to it the following sampleadd
function:Running the migration fails with the following error:
Expected behavior
The migration should complete.
Screenshots
If applicable, add screenshots to help explain your problem.
System information