Closed bhargavik12 closed 2 years ago
interval used in queries are not working
Wops.
Yes, the implementation of binary operators is pretty simplistic... they assume that both left & right values have the same types, and that the underlying JS primitive supports the "+" operator.
You just found a case where neither of those statements are true.
This issue would require to implement custom operators declaration (like custom functions, but for operators).
Will do. Thanks for the report !
Ran into this issue as well with this statement
select * from some_tale where created_at > NOW() - INTERVAL '1 DAY' * '4';
Ran into this as well when doing the following command:
UPDATE rooms SET expiration_date = CURRENT_TIMESTAMP + (10 * '1 minute'::interval)
Getting:
Error: cannot cast type interval to integer
Any solution to this?
Hi,
Too many people had troubles with the lack of support of +/- on interval & date types.
pg-mem is not ready yet to fully support custom operators, but I added to a hack to support this specific use case.
This shipped with with pg-mem@2.1.8
. Sorry for the wait, I should have done that much sooner.
Awesome! Thanks for the support on this one.
An insert query
create table test (col timestamp); insert test (col) values (NOW() + interval '2 years')
data: { error: 'cannot cast type interval to timestamp', code: undefined }, location: { start: 0, end: 0 }