Open govidat opened 4 years ago
Docs definitely need clarification. The @>
(cs) works both for array and range types. That's why the {}
(array literal) notation is mentioned in some parts and others have [)
(range literal).
Workaround:
# in sql
select * from mytable WHERE validity @> '[2020-07-21,2020-07-21]';
# in postgrest
curl 'localhost:3000/mytable?validity=cs.\[2020-07-21,2020-07-21\]'
Not ideal to duplicate the value, but it should work.
Should we parse the cs
operand(cs.2020-07-21
) to allow accepting a single value as well?
Seems possible. If no {
or [
is detected, then we cast the value.
It's kind of related to the proposal in https://github.com/PostgREST/postgrest/issues/1569#issuecomment-673610581. We may have to think if we should offer these facilities for better UX.
Environment
Description of issue
I have a daterange field (eg validity) and am trying to get if current_date is in the daterange.
As per postgrest documentation , we need to use: cs - contains e.g. ?tags=cs.{example, new} Two issues are noticed:
(Steps to reproduce: Include a minimal SQL definition plus how you make the request to PostgREST and the response body) In pg the following select works correctly: select from mytable WHERE validity @> '2020-07-21'::date;
or select from mytable WHERE validity @> current_date;
Whereas, with postgrest it works only on cs.[from_date, to_date].