I added two custom fields with naive_datetime type to one of my schemas and even though everything seems right (inserting, loading data), when i run tests against it, it gives an error comparing values on microseconds (0 != 6).
IIRC (and I may not) Ecto will set the microsecond precision to 6 because thats what Postgres will return whereas the default NaiveDateTime will set the precision to 0.
If you use NaiveDateTime.compare/2 I think you’ll find they’ll be :eq meaning equal.
In Ecto master we will have naive_datetime and naive_datetime_usec, exactly to solve issues like this. Elixir v1.6 will also include a NaiveDateTime.truncate function, which makes it easier to set a given precision.
Thank you for feedback Kip, i used compare, but i was having issues in matching operations on my tests, at the point where i felt, there should be a better way to handle this
That’s great news José, thank you for the great work put on those projects, and the feedback of course