lpil / pog

🐘 A PostgreSQL database client for Gleam, based on PGO
https://hexdocs.pm/pgo
Apache License 2.0
146 stars 13 forks source link

Timestamps fail to decode due to microseconds. #41

Closed ceedon closed 2 weeks ago

ceedon commented 1 month ago

Common pg built-ins like now() add microseconds. This causes decode_timestamp https://github.com/lpil/pgo/blob/3c7926125ff3050c1ac378eede6513762e0c0571/src/gleam/pgo.gleam#L531 to error as it's expecting #(#(Int, Int, Int), #(Int, Int, Int)) and receives #(#(Int, Int, Int), #(Int, Int, Float)).

Is this intentional? Feels like changing the last element to a Float would work in both cases.

lpil commented 1 month ago

Hello! We've been having some discussion to determine what to do about this, and with time types in general. Sorry about the problem. As a work-around you can truncate the time in your SQL code

ceedon commented 1 month ago

Yeah, plenty of ways around it. Made the magic of squirrel decidedly less magical is all! Thanks for taking a look.

giacomocavalieri commented 2 weeks ago

This should be fixed now that pog has its own time type with microseconds!

ceedon commented 2 weeks ago

Neat! I'll play guinea pig tonight.

lpil commented 2 weeks ago

Thanks folks!