Closed AuroraTea closed 12 months ago
Yep. For nullable values use []sql.NullInt64 and pq.Array(). From the docs:
var x []sql.NullInt64
db.QueryRow(`SELECT ARRAY[235, 401]`).Scan(pq.Array(&x))
New to the use of pq.Array(&x)
, thank you @cbandy very much!
I usually prefer to use int64 (NULL will be nil), but[]int64 here is not work withparsing array element index 0: strconv.ParseInt: parsing "": invalid syntax[]
, []sql.NullInt64 is OK. Is there still a way to use *int64?
pq.Int64Array and other Array types, in {NULL} will report an error pq: parsing array element index 0: strconv.ParseInt: parsing "": invalid syntax And {NULL} is still very common in LEFT OUTER JOIN