Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tapdb: fix time zone issue with timestamps
Because sqlc by default just uses the time.Time.String() method to turn a timestamp into the DB value, the time zone of the timestamp has an impact as any SQL query would basically be a string comparison that doesn't look at the time zone at all. For example: WHERE a < b Would be true for a = '2023-09-26 14:00:00 GMT-8' (22:00 local time) a = '2023-09-26 15:00:00 UTC' (15:00 local time) Even though 10pm is clearly after 3pm. To fix this, we explicitly call .UTC() on any time.Time we use in any SQL query. The only instances where that was not yet the case in the whole tapdb package were the newly added queries for UTXO leases. It seems that with a later release of the sqlite driver we could customize this behavior of how a timestamp is being formatted. But for now the .UTC() workaround should work as well.
- Loading branch information