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
Preparing a named statement for this passes just fine (if nmStmt, err = db.PrepareNamed("INSERT INTO someTbl (id, net) VALUES (:id, :net);"); err != nil {...).
However, upon actually trying to execute it (if res, err = nmStmt.Exec(&MyStruct{ID: 3, Network: netip.MustParsePrefix("192.168.1.0/24")}); err != nil {...), the execution will fail with an unsupported type netip.Prefix, a struct error.
Even if the target column data type is a SQLite TEXT.
Now, because this is stdlib, I'd have to coerce type it, which leads to a lot of what is probably unnecessary code because this is a stdlib type that indicates that it can both marshal and unmarshal itself to/from both text and bytes.
Does sqlx do any sort of on-the-fly marshaling/unmarshaling like that, or is this likely instead an issue with the driver (in this case, the recommended github.com/mattn/go-sqlite3 per here)?
The text was updated successfully, but these errors were encountered:
Certain types, many stdlib (e.g. a
net/netip.Prefix
) implement a:encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
encoding.TextMarshaler
encoding.TextUnmarshaler
These interfaces, notably
encoding.TextUnmarshaler
/encoding.TextMarshaler
, should most likely be used where the DB field type supports it.For example:
Preparing a named statement for this passes just fine (
if nmStmt, err = db.PrepareNamed("INSERT INTO someTbl (id, net) VALUES (:id, :net);"); err != nil {...
).However, upon actually trying to execute it (
if res, err = nmStmt.Exec(&MyStruct{ID: 3, Network: netip.MustParsePrefix("192.168.1.0/24")}); err != nil {...
), the execution will fail with anunsupported type netip.Prefix, a struct
error.Even if the target column data type is a SQLite
TEXT
.Now, because this is stdlib, I'd have to coerce type it, which leads to a lot of what is probably unnecessary code because this is a stdlib type that indicates that it can both marshal and unmarshal itself to/from both text and bytes.
Does sqlx do any sort of on-the-fly marshaling/unmarshaling like that, or is this likely instead an issue with the driver (in this case, the recommended
github.com/mattn/go-sqlite3
per here)?The text was updated successfully, but these errors were encountered: