Open sleddev opened 9 months ago
i encountered the same issue, @sleddev did you manage to sort it out?
@carlcris I ended up making type aliases, and implementing my own Scan
and Value
functions on those types.
Here's my current implementation: https://gist.github.com/sleddev/17ddd0e5f2a037ecf7bb6527367cb916
There may be edge cases I didn't account for, but from my testing and usage works nicely.
To use it, just swap []float64
to pg.Float8Array
in your model
GORM Playground Link
https://github.com/go-gorm/playground/pull/668
Description
Explain your user case and expected results
When inserting go arrays or slices in a GORM model, the generated SQL uses them as records, so the insert fails.
For example:
gives the SQL:
And I get the error
ERROR: column "data" is of type double precision[] but expression is of type record (SQLSTATE 42804)
Instead, the SQL should be:
or
If I use pgx directly, and do:
It works as expected, generating SQL with the
'{...}'
syntax