canonical / sqlair

Friendly type mapping for SQL databases
Apache License 2.0
16 stars 8 forks source link

Scanning into time.Time #147

Closed Aflynn50 closed 2 months ago

Aflynn50 commented 2 months ago

If a row in a database is null, then SQLair will return the zero value for the type. It does this by passing a pointer to the type to Rows.Scan and if that sets the pointer to nil it sets output to its zero value. Rows.Scan does support scanning into time.Time but for some reason, not *time.Time. This means it is impossible to use SQLair to scan directly into the time.Time type.

Aflynn50 commented 2 months ago

Turns out this was user error, I was using MAX to select the time and was returning it as a string not a timestamp which the driver did not expect.