-
-
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
Feature request: support for filter/condition that is always false (ie. where false) #1121
Comments
It makes sense to allow LIMIT 0 from the PostgreSQL side, however from the HTTP side we're mapping the usage of Saw a discussion regarding this, seems we can ignore the Another option is to allow a |
The suggested
would work well for my needs, however, I don't know that I have enough postgrest specific context to weigh in on whether or not this change makes sense for the project as a whole. With that being said, I am under the impression that the surface level client API issues (presented in this issue) will occur in other clients (assuming they create a |
It's not really required that we map our I think we can make an exception(for |
@steve-chavez can I sum up this thread/feature request as, the following GET request should not fail?
Its returning 416 now and it should return a blank array right? |
@gautam1168 Yes, correct! |
@steve-chavez I have figured out what I need to do to make this work. I am a bit conflicted about one change that I will have to make though. I will have to change the
Do you think this is a safe change to make? Or is there a reason for this function to panic if Range without lower boundary is coming in from somewhere? Alternatively I can modify the implementation of
Can you point me to which one of these would be the preferred change? I am guessing the second one right? |
@gautam1168 Yeah, that seems simpler and better(the RangeQuery.hs module has been pretty stable/focused, changes have been too rare). Go for it! |
@steve-chavez I have been trying to make it work by modifying the code in
But also, I can see that changing the behaviour of I know this looks like a dangerous change and perhaps not a beginner one. But Ill try to open a PR and then see how it goes. If it can't be merged, then it can't be merged. I have checked that postgres supports queries like
so, this is possible, but its a slightly more impactful change than perhaps was anticipated. |
First and foremost, thank you very much for your time
Summary
I've discussed this issue in the past on gitter, however, I thought I'd make a more formal request for this functionality. In short, I'm in need of support for a filter/condition that always fails (ie. where false). This request is a matter of elegance/beauty + handling edge cases rather than desiring new functionality.
In sql terms, what I'm requesting is something along the lines of:
... where false
We already have support for:
... where true
through implicit means (specifying no filters).
Context
I'm the author of elm-postgrest, and I'm under the impression that this functionality would allow my API to be more elegant + simpler (and I assume the same will be true for other client libraries). Let me try to demonstrate (examples will be in elm, however, those familiar with haskell should feel at home).
Let's start by looking at the current/desired API for a readMany request in elm-postgrest:
and now some example usage:
as you can see
PG.true
has the type:In addition to
PG.true
, elm-postgrest also supportsPG.not
. This function has the type:And, by extension of having both
PG.true
andPG.not
, in order for things to remain consistent, we must also havePG.false
.Now, to be clear, I understand that I could represent the
PG.true
case with something other than a "true"Condition attributes
. For example,readMany
could have the type:and example usage being:
and if that were the only case where this fudged the api, I may feel differently regarding the need for this feature, however, there is in fact one other place where the API suffers and that's with the 2 functions
PG.all
andPG.any
(representing postgrest and + or respectively). Those functions have the types:In order for these functions to work as expected, they need to have the behavior:
Once again, I'm aware of the API change to
all
andany
in order to avoid this issue:however, it is at this point that I began to question its elegance.
Workarounds
If support for
limit 0
were added, I may be able simulate the behavior that I need. We can discuss/explore this point further if need be.The text was updated successfully, but these errors were encountered: