You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a service using restler. It has a resource, e.g. BookResource, which has overridden ServiceResource<V, K>.getServiceQueryParams() to add a default query parameter e.g. type=null.
Thus you can retrieve books like
GET /book/-;Author=Erik
to get books by Erik (which where type==null).
How to trigger the bug
We want to override the default value, and get books where type != null, so we try
GET /book/-;type__ne=$null
This does not work, you don't get the expected results. Adding /info to the query reveals that the real query was
The problem is that in restdsl.util.RequestUtil.parseRequest() we use parsedQueryField.getFullCriteria() as the key in our multimap, and in this case the key for our queryparam type__ne=$null is type <>. The default value for "type" is stored with the key type.
The effect of this is that in restdsl.queries.ServiceQuyery:applyServiceQueryParams() where we merge the default parameters to the user provided ones, that we don't replace them as the key for the user provided query parameter was type <> and not type.
Setup
There is a service using restler. It has a resource, e.g.
BookResource
, which has overriddenServiceResource<V, K>.getServiceQueryParams()
to add a default query parameter e.g.type=null
.Thus you can retrieve books like
to get books by Erik (which where
type==null
).How to trigger the bug
We want to override the default value, and get books where
type != null
, so we tryThis does not work, you don't get the expected results. Adding /info to the query reveals that the real query was
returns
, so the default value was not overridden!
Where the problem comes from
The problem is that in restdsl.util.RequestUtil.parseRequest() we use
parsedQueryField.getFullCriteria()
as the key in our multimap, and in this case the key for our queryparamtype__ne=$null
istype <>
. The default value for "type" is stored with the keytype
.The effect of this is that in restdsl.queries.ServiceQuyery:applyServiceQueryParams() where we merge the default parameters to the user provided ones, that we don't replace them as the key for the user provided query parameter was
type <>
and nottype
.Possible solution
Use
as the key in the multimap instead. Then the default value would get properly replaced.
The implication is that this not a backwards compatible fix, as it changes how queries are made => version bump?
The text was updated successfully, but these errors were encountered: