-
-
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
Swagger: GET record from table with uuid primary key: failed to parse filter #1970
Comments
This will not work right now. We had some ideas in #1949 (comment) and #1949 (comment) that would make this work - but those are far from being implemented, yet. |
I see it now. So as Wolfgang mentioned, our current syntax is a problem for swagger-ui. Because it's like:
The value being
Then the value would be valid. Function calls should work fine with swagger-uid though, because they use the required form of Seems that |
I think the above problem with We could change this: GET /people?or=(grade.gte.90,student.is.true) To: GET /people?grade.gte=90&student.is=true&or=grade.gte,student.is Or as a shorthand: GET /people?grade.gte=90&student.is=true&or=* This works because on the new syntax we can make the filter at the left side unique, unlike the current syntax where Besides swagger-ui, other advantage I see is that with this new Grouping could still be done as: GET /people?age.gte=11&age.lte=17&age.eq=14&or=age.eq,not.and(age.gte,age.lte) |
My initial reaction to this was: Oh noo. Separating logic from the filters will just create additional complexity. But the more I think about it, the more I see the upside of this, too.
Do we already support multiple filters with the same name before the If that's the case, I wouldn't want to give up on that. Otherwise a Maybe we can add aliasing to it? So basically make it unique, but allow this: GET /people?age15:age.eq=15&age17:age.eq=17&or=age15,age17
❤️
Instead of making the top-level an GET /people?age.gte=11&age.lte=17&age.eq=14&logic=or(age.eq,not.and(age.gte,age.lte)) or with aliases: GET /people?min:age.gte=11&max:age.lte=17&age.eq=14&logic=or(age.eq,not.and(min,max)) |
Just tried that, we do :/ - it's undocumented, would like to keep it that way.
That could be changed to an
IMHO it seems too complex, and we'd only need for that for a URL workaround(no sense in aliasing filters in SQL). For a REST syntax v2, I think it'd be better to just make each query param unique. That way the syntax would be kept simpler. |
Though as I see it on #2063 (comment), Hm, I think fixing that for a v2 would be a matter of adding the |
One problem is that |
I gave it a second thought and making each param unique seems too breaking, many users are already used to doing
Yes, aliasing looks like the way forward. We could still offer the
Thinking about the So currently it could be like: GET /people?min:age=gte.11&max:age=lte.17&age=eq.14&logic=or(age.eq,not.and(min,max)) |
Another thing, if no aliasing is added like above, then the
Which would also help to keep the url shorter, in cases where or is wanted for all filters. |
Adding the logic parameter would always be a breaking change, because Using
|
Though this one would be fixed by moving the operators to the left side(as proposed on #2066), it would also be possible to have at least the So This would at least solve this issue since it's related to |
Big thumbs up for defaulting to an eq in the absence of an operator where one is assumed! And yes longer term #2066 looks like a really neat way to allow the operators to extend basic functionality rather than trip noobs up when they try and use the basics |
And great timing I was just starting to write an nginx rewriter to mangle the eqs into requests from swagger :) |
I don't think we should default to Instead, the correct solution seems to me to add variants for each operator to the OpenAPI So right now, we have something like this:
but we should have something like:
|
This should be done only after we move the operator from |
Correct. |
Environment
(Using this: https://github.com/johnnylambada/docker-postgrest-swagger-sample)
Description of issue
On swagger I try to GET a record from a table where the primary key is a UUID.
As a result I get:
I think this error originates from postgrest.
On the other hand if I try a filter like 'eq.3922488c-18bc-45d8-baa2-bdb10cd90e37' the action is refused by swagger, because the string with filter does not follow the uuid format.
How do I resolve this?
The text was updated successfully, but these errors were encountered: