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
We're using (and loving!) the new sqlc.embed function, but ran into what seems to be a bug, where using embed causes sqlc not to wrap text[] fields in a pq.Array function, which causes a unsupported Scan, storing driver.Value type <nil> into type *[]string at runtime. Replacing the sqlc.embed(records) call with a records.* fixes the array issue, but of course means maintaining a conversion function into a struct.
This happened on a query doing some joins, but in the reproduction also happens on a single-table query.
Minimal Reproduction
In the sqlc Playground, you can see that:
the text_list and int_list fields are of type text[] and int[]
first query uses a records.* for SELECT, and the second query uses sqlc.embed(records)
These should have essentially the same output, but in the generated query.sql.go file, the first query wraps the lists in a pq.Array, while the second does not.
This leads to an unsupported Scan, storing driver.Value type <nil> into type *[]string error at runtime.
Relevant log output
unsupported Scan, storing driver.Value type<nil> into type*[]string
Database schema
CREATETABLErecords (
id BIGSERIALPRIMARY KEY,
text_list text[],
int_list int[]
);
Version
1.18.0
What happened?
We're using (and loving!) the new
sqlc.embed
function, but ran into what seems to be a bug, where usingembed
causes sqlc not to wraptext[]
fields in apq.Array
function, which causes aunsupported Scan, storing driver.Value type <nil> into type *[]string
at runtime. Replacing thesqlc.embed(records)
call with arecords.*
fixes the array issue, but of course means maintaining a conversion function into a struct.This happened on a query doing some joins, but in the reproduction also happens on a single-table query.
Minimal Reproduction
In the sqlc Playground, you can see that:
text_list
andint_list
fields are of typetext[]
andint[]
records.*
for SELECT, and the second query usessqlc.embed(records)
query.sql.go
file, the first query wraps the lists in apq.Array
, while the second does not.unsupported Scan, storing driver.Value type <nil> into type *[]string
error at runtime.Relevant log output
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/bd6670f67d7952178f3aa96d510cc9f84787bbb079fe791eeaca80fa33300606
What operating system are you using?
macOS
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: