mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-17 20:50:44 +00:00
Update to accept query & filter as POST
This commit is contained in:
@ -278,6 +278,7 @@ public class QJavalinImplementation
|
||||
path("/data/{table}", () ->
|
||||
{
|
||||
get("/", QJavalinImplementation::dataQuery);
|
||||
post("/query", QJavalinImplementation::dataQuery);
|
||||
post("/", QJavalinImplementation::dataInsert); // todo - internal to that method, if input is a list, do a bulk - else, single.
|
||||
get("/count", QJavalinImplementation::dataCount);
|
||||
get("/export", QJavalinImplementation::dataExportWithoutFilename);
|
||||
@ -606,6 +607,10 @@ public class QJavalinImplementation
|
||||
queryInput.setLimit(integerQueryParam(context, "limit"));
|
||||
|
||||
String filter = stringQueryParam(context, "filter");
|
||||
if(!StringUtils.hasContent(filter))
|
||||
{
|
||||
filter = context.formParam("filter");
|
||||
}
|
||||
if(filter != null)
|
||||
{
|
||||
queryInput.setFilter(JsonUtils.toObject(filter, QQueryFilter.class));
|
||||
|
@ -285,6 +285,30 @@ class QJavalinImplementationTest extends QJavalinTestBase
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** test a table query using an actual filter via POST.
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
public void test_dataQueryWithFilterPOST()
|
||||
{
|
||||
String filterJson = getFirstNameEqualsTimFilterJSON();
|
||||
HttpResponse<String> response = Unirest.post(BASE_URL + "/data/person/query")
|
||||
.field("filter", filterJson)
|
||||
.asString();
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
JSONObject jsonObject = JsonUtils.toJSONObject(response.getBody());
|
||||
assertTrue(jsonObject.has("records"));
|
||||
JSONArray records = jsonObject.getJSONArray("records");
|
||||
assertEquals(1, records.length());
|
||||
JSONObject record0 = records.getJSONObject(0);
|
||||
JSONObject values0 = record0.getJSONObject("values");
|
||||
assertEquals("Tim", values0.getString("firstName"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
Reference in New Issue
Block a user