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
Things have change to using pgtype.* for certain fields.
Note i had to change the limit and offset to be named inputs.
LIMIT $1 OFFSET $2; to LIMIT sqlc.arg(row_limit) OFFSET sqlc.arg(row_offset); this is related to #3840 i think
NB
the playground wont render my example at all, so i have provided 2 playground links. a working one has a hardcoded value instead of the named parameter @tags with doesnt work
Relevant log output
There is no log output, just an error in the generated go code.
-- name: CountChanges :oneSELECTcount(*)
FROM changes
WHERE account_name = @account_name
AND (
creator_name = ANY(@author::text [])
OR @author IS NULL
)
AND (
repo = ANY(@repo::text [])
OR @repo IS NULL
)
AND (
status = ANY(@status::int [])
OR @status IS NULL
)
AND (
(
1= ANY(@risks::int [])
AND num_low_risks >0
)
OR (
2= ANY(@risks::int [])
AND num_medium_risks >0
)
OR (
3= ANY(@risks::int [])
AND num_high_risks >0
)
OR ARRAY_LENGTH(@risks, 1) IS NULL
)
AND (
(
SELECT jsonb_object_agg(
key,
COALESCE(
value->'userTagValue'->>'value',
value->'autoTagValue'->>'value'
)
)
FROM jsonb_each(enriched_tags->'tagValue')
) @>'{"security": null}'OR @tags IS NULL
);
-- name: ListChanges :manySELECT*FROM changes
WHERE account_name = @account_name
AND (
creator_name = ANY(@author::text [])
OR @author IS NULL
)
AND (
repo = ANY(@repo::text [])
OR @repo IS NULL
)
AND (
status = ANY(@status::int [])
OR @status IS NULL
)
AND (
(
1= ANY(@risks::int [])
AND num_low_risks >0
)
OR (
2= ANY(@risks::int [])
AND num_medium_risks >0
)
OR (
3= ANY(@risks::int [])
AND num_high_risks >0
)
OR ARRAY_LENGTH(@risks, 1) IS NULL
)
AND (
(
SELECT jsonb_object_agg(
key,
COALESCE(
value->'userTagValue'->>'value',
value->'autoTagValue'->>'value'
)
)
FROM jsonb_each(enriched_tags->'tagValue')
) @>'{"security": null}'OR @tags IS NULL
)
ORDER BY CASE
WHEN @order_by::int=0 THEN title
END ASC,
CASE
WHEN @order_by =1 THEN title
END DESC,
CASE
WHEN @order_by =2 THEN created_at
END ASC,
CASE
WHEN @order_by =3 THEN created_at
END DESCLIMITsqlc.arg(row_limit) OFFSET sqlc.arg(row_offset);
Version
1.25.0
What happened?
Summary
adding a subquery with jsonb_each affects the generated golang type.
For postgres we are wanting to filter on a jsonb column. there are 2 queries one to calculate a count. And a second query to return the data.
we used to have a simple part to the where clause on a json field.
but it has now moved to be a more complex subquery using jsonb_each
This has affected the generated golang types substantially.
Original Data structure looked like
with the more complex filter, we get the following data structure.
Things have change to using pgtype.* for certain fields.
Note i had to change the limit and offset to be named inputs.
LIMIT $1 OFFSET $2;
toLIMIT sqlc.arg(row_limit) OFFSET sqlc.arg(row_offset);
this is related to #3840 i thinkNB
the playground wont render my example at all, so i have provided 2 playground links. a working one has a hardcoded value instead of the named parameter @tags with doesnt work
Relevant log output
There is no log output, just an error in the generated go code.
Database schema
SQL queries
Configuration
Playground URL
working with workaround
) @> '{"security": null}'
https://play.sqlc.dev/p/a67edcd2f245f6bfeda821c3ebca935fb253669807f1fd036c88c69f0a5025f1
failing with named parameter @tag
https://play.sqlc.dev/p/2bc14cfff5e578faa111eecae99407dfaa94b55b4b4a28b2366e720f703ae9e9
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: