fix: cast date columns to ::date
The current version casts dates to ::timestamptz
regardless of the column type.
This forces the use of zeroed dates when querying date
columns, as any minute/second/ms will prevent any row from matching. It also causes issues with time zones if node and the server are not using the same tz (e.g. one using UTC one using local).
For customers.find({ birthdate: new Date(1980, 0, 1) })
SELECT * FROM customers WHERE birthdate = '1980-01-01T00:00:00+00:00'::timestamptz -- doesn't work unless pg is UTC
SELECT * FROM customers WHERE birthdate = '1980-01-01T00:00:00.001'::timestamptz -- doesn't work
SELECT * FROM customers WHERE birthdate = '1980-01-01T00:00:00+00:00' -- OK
SELECT * FROM customers WHERE birthdate = '1980-01-01T00:00:00.001' -- OK
SELECT * FROM customers WHERE birthdate = '1980-01-01T00:00:00+00:00'::date -- OK
SELECT * FROM customers WHERE birthdate = '1980-01-01T00:00:00.001'::date -- OK
PR adds type information to Readable.columns
and casts to ::date
for date
columns.