Replies: 1 comment
-
After doing a bunch of searching I was able to find this suggestion #2997 (comment) which creates a Postgres In my case, this is would be the solution: -- Create the view below in a migration file
CREATE VIEW participant_user AS (
SELECT
"participant".*,
"user"."name" AS "user_name",
"user"."email" AS "user_email",
"user"."image_url" AS "user_image_url"
FROM "participant"
LEFT JOIN "user" ON "user"."id" = "participant"."user_id"
);
-- name: FindAllEvents :many
SELECT
sqlc.embed(event),
sqlc.embed(p),
FROM "event"
JOIN "participant_user" p ON p.event_id = "event".id; It would be helpful if sqlc could determine that nullable refs should always use the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a relatively simple query that returns all events with a join on 2 tables.
This query generates the following code:
The problem with this generated code is that the
FindAllEventsWithUserRow.User
field could benil
since theparticipant.user_id
column is nullable. However, since the generated code doesn't take that into account and tries to scan&i.User.ID
we get the following runtime error:Is there any way this can be fixed or addressed? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions