-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow 'in.' filter to have no items #641
Comments
can you show the sql query you are trying to generate and how it is useful? |
Doesn't matter. the result will always be an empty result set.
See the linked admin-config issue: it expects there to be an API call that returns things in set X. But then it passes an empty set as X. |
At this point this seems to me like a way to fix deficiencies in the client by patching the backend. if postgrest treats this as a bad request select * from test.projects p
where p.id in () i don't see why we should accept it as a valid request |
That's a reasonable argument. The thing is, at the moment postgrest converts it to the empty string: select * from test.projects p
where p.id in ("") |
Just in case you might be counting votes/opinions: |
On a different note, @daurnimator and others, how would you suggest the user should put the query string if they actually want exactly this query with the empty string? In fact, you could argue that what the user put behind the "in." part is the empty string. You merely cannot distinguish the empty string from nothing, or is there a meaningful way? |
@SebAlbert empty set might be valid in some domains but not here, we are talking about sql and |
i.e. please show me a query with |
You're right, it's not valid. To my mind, a use case, however, would be "not having to fiddle with special cases" in frontend code, just like in this issue here. |
There are two reasons that I think we should allow
|
|
In postgres |
@daurnimator That might be true, but it's not for us mortals to judge :) |
@ruslantalpa The query |
Possible, i'll look at it again a bit later
|
the request the problem with this is that when generating the query, we would need to know beforehand the type of the column to switch |
If someone wants to detect if name is the empty string they could still do
Simply turn it to false in sql since we know that |
if it's valid sql and if it's one size fits all (column types) i'm for it |
Yikes I've let this issue languish! I can work on the fix for this one. Adding a tag to the issue. |
@begriffs @ruslantalpa @SebAlbert maybe we should think of the And since In fact, PostgreSQL even converts view definitions using For example: create view test_view as
select *
from pg_database
where datname in ('template1', 'template2'); Gets created as: postgres=# \d+ t5
...
View definition:
SELECT pg_database.datname,
pg_database.datdba,
pg_database.encoding,
pg_database.datcollate,
pg_database.datctype,
pg_database.datistemplate,
pg_database.datallowconn,
pg_database.datconnlimit,
pg_database.datlastsysoid,
pg_database.datfrozenxid,
pg_database.datminmxid,
pg_database.dattablespace,
pg_database.datacl
FROM pg_database
WHERE pg_database.datname = ANY (ARRAY['template1'::name, 'template2'::name]); |
PostgREST#641: allow IN filter to have no values (PostgREST#854)
When
in.
is not followed by any characters, treat it as the empty set.Related to marmelab/admin-config#71
I'm using the code:
However, if the filter list is empty, it ends up requesting the path
/organisation?id=in.
. This comes back from postgrest as a 400 error:The text was updated successfully, but these errors were encountered: