Bug Report
When using a nested Query object within the whereIn method, the generated API request incorrectly escapes the JSON of the nested query, leading to a failed API call.
To Reproduce
Initialize a Query object as a sub-query:
subQuery = stack.contentType("some-name").query().where("uid","blt407c1431a725f925")
Apply this subQuery using whereIn on a main query:
query.whereIn("my_propertyname", subQuery)
Expected behavior
The generated API request URL should correctly represent the nested query as a JSON object within the $in_query operator, like this:
https://eu-cdn.contentstack.com/v3/content_types/my_contenttype/entries?environment=live&query={"my_propertyname":{"$in_query":{"uid":"blt407c1431a725f925"}}}
Current behavior
The generated API request URL incorrectly escapes the nested query's JSON, treating it as a string:
https://eu-cdn.contentstack.com/v3/content_types/my_contenttype/entries?environment=live&query={"my_propertyname":{"$in_query":"{\"uid\":\"blt407c1431a725f925\"}"}}
This results in the following error from Contentstack:
Contentstack fetch entry request failed with status 141 and message: Failed to fetch entries. Please try again with valid parameters.
Additional context
The relevant code for the Query class can be found here: https://github.com/contentstack/contentstack-java/blob/master/src/main/java/com/contentstack/sdk/Query.java#L1433
A potentially related unit test that may not fully cover this scenario:
|
void testUnitQueryWhereIn() { |
Bug Report
When using a nested Query object within the whereIn method, the generated API request incorrectly escapes the JSON of the nested query, leading to a failed API call.
To Reproduce
Initialize a Query object as a sub-query:
subQuery = stack.contentType("some-name").query().where("uid","blt407c1431a725f925")Apply this subQuery using whereIn on a main query:
query.whereIn("my_propertyname", subQuery)Expected behavior
The generated API request URL should correctly represent the nested query as a JSON object within the $in_query operator, like this:
https://eu-cdn.contentstack.com/v3/content_types/my_contenttype/entries?environment=live&query={"my_propertyname":{"$in_query":{"uid":"blt407c1431a725f925"}}}
Current behavior
The generated API request URL incorrectly escapes the nested query's JSON, treating it as a string:
https://eu-cdn.contentstack.com/v3/content_types/my_contenttype/entries?environment=live&query={"my_propertyname":{"$in_query":"{\"uid\":\"blt407c1431a725f925\"}"}}
This results in the following error from Contentstack:
Contentstack fetch entry request failed with status 141 and message: Failed to fetch entries. Please try again with valid parameters.
Additional context
The relevant code for the Query class can be found here: https://github.com/contentstack/contentstack-java/blob/master/src/main/java/com/contentstack/sdk/Query.java#L1433
A potentially related unit test that may not fully cover this scenario:
contentstack-java/src/test/java/com/contentstack/sdk/TestQueryCase.java
Line 985 in e469599