Open austincollinpena opened 8 months ago
I really like sqlc but every time I come back to it I run into this use case. Supporting it natively would be great!
Any news?
This isn't what sqlc.embed does. Embedded structs are just a way to allow for code reuse of common collections of fields. If it were otherwise and the generated code took the returned rows and manipulated them to produce a struct with a one-to-many relationship, that function would then return fewer rows than you would expect from the SQL.
sqlc is just a library to generate type-safe SQL that output the returned queries as named structs. It's helpful boilerplate generation but its still just SQL and row scanning under the hood. It's not an ORM.
Related issues regarding left joins #2348 and #2997 could be a good start. Also see related discussion #2643.
What do you want to change?
Given this query:
Where each
swipe_sub_category
has a foreign key relationship to category, I would expect the generated struct to be this:and not this:
Am I missing how to use this feature?
What database engines need to be changed?
PostgreSQL
What programming language backends need to be changed?
Go