-
Notifications
You must be signed in to change notification settings - Fork 92
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
Querystring behaviour is inconsistent when integrating other Loopback APIs #324
Comments
same as #320 |
Hey @horiaradu, what version of I just tried to reproduce the issue and it was working as expected. Either that, or I don't entirely understand the issue. You're saying that when you use an empty array, it returns all the results instead of none? |
The issue I posted is still relevant in how querystring handles arrays throwing object ids on top just makes the whole scenario worse. I was getting 413 errors due to the querystring being to large for nginx to process, check my referenced issue to find an example in tonicdev you can play with. In the mean time I too have forked and introduced a similar patch. cheers |
More detailed scenario: There is a model I am doing a query like bellow:
I've put the So, I don't get any results from
And here is where |
Sorry @horiaradu, I didn't quite understand what you were describing right away. I still can't reproduce the issue with strong-remoting alone (I'm on 2.29.0, no sure if that makes a difference). I get an empty array when I try to hit the following: I do however see that when you pass Thanks for your patience, I'm sure this is easier to understand than I am making it. |
I have updated my PR so that the tests pass (forgot a line...). |
Stringify query params which are objects in a way in which empty ararys are preserved instead of removed (default querystring implementation). fix: strongloop#324
Landed. |
Loopback has a particular interface for REST APIs. It allows you to write a query like so:
Model.find({where: {id: {inq: [1, 2, 3]}}})
However, this query is also valid:
Model.find({where: {id: {inq: []}}})
, but it will obviously not return any results.In this case, the generated query looks like this:
and decoded, like this:
The problem is inside http-invocation.js, line: 215.
Querystring behaviour (from node REPL):
If you are integrating another loopback API, when you do the query with an empty array, you expect to get back an empty collection of items, but instead, because of the behaviour of querystring, you get back all the items.
See related issues:
The text was updated successfully, but these errors were encountered: