mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Merge branch 'dev' into feature/CTLE-434-oms-update-business-logic
This commit is contained in:
@ -30,6 +30,7 @@ public enum QCriteriaOperator
|
|||||||
{
|
{
|
||||||
EQUALS,
|
EQUALS,
|
||||||
NOT_EQUALS,
|
NOT_EQUALS,
|
||||||
|
NOT_EQUALS_OR_IS_NULL,
|
||||||
IN,
|
IN,
|
||||||
NOT_IN,
|
NOT_IN,
|
||||||
IS_NULL_OR_IN,
|
IS_NULL_OR_IN,
|
||||||
|
@ -131,6 +131,7 @@ public class BackendQueryFilterUtils
|
|||||||
{
|
{
|
||||||
case EQUALS -> testEquals(criterion, value);
|
case EQUALS -> testEquals(criterion, value);
|
||||||
case NOT_EQUALS -> !testEquals(criterion, value);
|
case NOT_EQUALS -> !testEquals(criterion, value);
|
||||||
|
case NOT_EQUALS_OR_IS_NULL -> !testEquals(criterion, value) || testBlank(criterion, value);
|
||||||
case IN -> testIn(criterion, value);
|
case IN -> testIn(criterion, value);
|
||||||
case NOT_IN -> !testIn(criterion, value);
|
case NOT_IN -> !testIn(criterion, value);
|
||||||
case IS_BLANK -> testBlank(criterion, value);
|
case IS_BLANK -> testBlank(criterion, value);
|
||||||
|
@ -113,6 +113,13 @@ class BackendQueryFilterUtilsTest
|
|||||||
assertFalse(BackendQueryFilterUtils.doesCriteriaMatch(new QFilterCriteria("f", QCriteriaOperator.NOT_IN, "A", "B"), "f", "B"));
|
assertFalse(BackendQueryFilterUtils.doesCriteriaMatch(new QFilterCriteria("f", QCriteriaOperator.NOT_IN, "A", "B"), "f", "B"));
|
||||||
assertTrue(BackendQueryFilterUtils.doesCriteriaMatch(new QFilterCriteria("f", QCriteriaOperator.NOT_IN, List.of()), "f", "A"));
|
assertTrue(BackendQueryFilterUtils.doesCriteriaMatch(new QFilterCriteria("f", QCriteriaOperator.NOT_IN, List.of()), "f", "A"));
|
||||||
assertTrue(BackendQueryFilterUtils.doesCriteriaMatch(new QFilterCriteria("f", QCriteriaOperator.NOT_IN, ListBuilder.of(null)), "f", "A"));
|
assertTrue(BackendQueryFilterUtils.doesCriteriaMatch(new QFilterCriteria("f", QCriteriaOperator.NOT_IN, ListBuilder.of(null)), "f", "A"));
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// NOT_EQUALS_OR_IS_NULL //
|
||||||
|
///////////////////////////
|
||||||
|
assertFalse(BackendQueryFilterUtils.doesCriteriaMatch(new QFilterCriteria("f", QCriteriaOperator.NOT_EQUALS_OR_IS_NULL, "A"), "f", "A"));
|
||||||
|
assertTrue(BackendQueryFilterUtils.doesCriteriaMatch(new QFilterCriteria("f", QCriteriaOperator.NOT_EQUALS_OR_IS_NULL, "A"), "f", "B"));
|
||||||
|
assertTrue(BackendQueryFilterUtils.doesCriteriaMatch(new QFilterCriteria("f", QCriteriaOperator.NOT_EQUALS_OR_IS_NULL, "A"), "f", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ public class OutboundAPILogMetaDataProvider
|
|||||||
new QPossibleValue<>(401, "401 (Not Authorized)"),
|
new QPossibleValue<>(401, "401 (Not Authorized)"),
|
||||||
new QPossibleValue<>(403, "403 (Forbidden)"),
|
new QPossibleValue<>(403, "403 (Forbidden)"),
|
||||||
new QPossibleValue<>(404, "404 (Not Found)"),
|
new QPossibleValue<>(404, "404 (Not Found)"),
|
||||||
|
new QPossibleValue<>(422, "422 (Unprocessable Entity)"),
|
||||||
new QPossibleValue<>(429, "429 (Too Many Requests)"),
|
new QPossibleValue<>(429, "429 (Too Many Requests)"),
|
||||||
new QPossibleValue<>(500, "500 (Internal Server Error)")
|
new QPossibleValue<>(500, "500 (Internal Server Error)")
|
||||||
)));
|
)));
|
||||||
@ -131,6 +132,7 @@ public class OutboundAPILogMetaDataProvider
|
|||||||
.withValue(AdornmentType.ChipValues.colorValue(401, AdornmentType.ChipValues.COLOR_ERROR))
|
.withValue(AdornmentType.ChipValues.colorValue(401, AdornmentType.ChipValues.COLOR_ERROR))
|
||||||
.withValue(AdornmentType.ChipValues.colorValue(403, AdornmentType.ChipValues.COLOR_ERROR))
|
.withValue(AdornmentType.ChipValues.colorValue(403, AdornmentType.ChipValues.COLOR_ERROR))
|
||||||
.withValue(AdornmentType.ChipValues.colorValue(404, AdornmentType.ChipValues.COLOR_ERROR))
|
.withValue(AdornmentType.ChipValues.colorValue(404, AdornmentType.ChipValues.COLOR_ERROR))
|
||||||
|
.withValue(AdornmentType.ChipValues.colorValue(422, AdornmentType.ChipValues.COLOR_ERROR))
|
||||||
.withValue(AdornmentType.ChipValues.colorValue(429, AdornmentType.ChipValues.COLOR_ERROR))
|
.withValue(AdornmentType.ChipValues.colorValue(429, AdornmentType.ChipValues.COLOR_ERROR))
|
||||||
.withValue(AdornmentType.ChipValues.colorValue(500, AdornmentType.ChipValues.COLOR_ERROR)));
|
.withValue(AdornmentType.ChipValues.colorValue(500, AdornmentType.ChipValues.COLOR_ERROR)));
|
||||||
|
|
||||||
|
@ -534,6 +534,12 @@ public abstract class AbstractRDBMSAction implements QActionInterface
|
|||||||
expectedNoOfParams = 1;
|
expectedNoOfParams = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case NOT_EQUALS_OR_IS_NULL:
|
||||||
|
{
|
||||||
|
clause += " != ? OR " + column + " IS NULL ";
|
||||||
|
expectedNoOfParams = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case IN:
|
case IN:
|
||||||
{
|
{
|
||||||
if(values.isEmpty())
|
if(values.isEmpty())
|
||||||
|
@ -148,6 +148,39 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
public void testNotEqualsOrIsNullQuery() throws QException
|
||||||
|
{
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 5 rows, 1 has a null salary, 1 has 1,000,000. //
|
||||||
|
// first confirm that query for != returns 3 (the null does NOT come back) //
|
||||||
|
// then, confirm that != or is null gives the (more humanly expected) 4. //
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
QueryInput queryInput = initQueryRequest();
|
||||||
|
queryInput.setFilter(new QQueryFilter()
|
||||||
|
.withCriteria(new QFilterCriteria()
|
||||||
|
.withFieldName("annualSalary")
|
||||||
|
.withOperator(QCriteriaOperator.NOT_EQUALS)
|
||||||
|
.withValues(List.of(1_000_000))));
|
||||||
|
QueryOutput queryOutput = new RDBMSQueryAction().execute(queryInput);
|
||||||
|
assertEquals(3, queryOutput.getRecords().size(), "Expected # of rows");
|
||||||
|
|
||||||
|
queryInput = initQueryRequest();
|
||||||
|
queryInput.setFilter(new QQueryFilter()
|
||||||
|
.withCriteria(new QFilterCriteria()
|
||||||
|
.withFieldName("annualSalary")
|
||||||
|
.withOperator(QCriteriaOperator.NOT_EQUALS_OR_IS_NULL)
|
||||||
|
.withValues(List.of(1_000_000))));
|
||||||
|
queryOutput = new RDBMSQueryAction().execute(queryInput);
|
||||||
|
assertEquals(4, queryOutput.getRecords().size(), "Expected # of rows");
|
||||||
|
Assertions.assertTrue(queryOutput.getRecords().stream().noneMatch(r -> Objects.equals(1_000_000, r.getValueInteger("annualSalary"))), "Should NOT find expected salary");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -895,12 +895,13 @@ public class QJavalinImplementation
|
|||||||
queryInput.getFilter().setLimit(limit);
|
queryInput.getFilter().setLimit(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryInput.setQueryJoins(processQueryJoinsParam(context));
|
List<QueryJoin> queryJoins = processQueryJoinsParam(context);
|
||||||
|
queryInput.setQueryJoins(queryJoins);
|
||||||
|
|
||||||
QueryAction queryAction = new QueryAction();
|
QueryAction queryAction = new QueryAction();
|
||||||
QueryOutput queryOutput = queryAction.execute(queryInput);
|
QueryOutput queryOutput = queryAction.execute(queryInput);
|
||||||
|
|
||||||
QJavalinAccessLogger.logEndSuccess(logPair("recordCount", queryOutput.getRecords().size()), logPairIfSlow("filter", filter, SLOW_LOG_THRESHOLD_MS));
|
QJavalinAccessLogger.logEndSuccess(logPair("recordCount", queryOutput.getRecords().size()), logPairIfSlow("filter", filter, SLOW_LOG_THRESHOLD_MS), logPairIfSlow("joins", queryJoins, SLOW_LOG_THRESHOLD_MS));
|
||||||
context.result(JsonUtils.toJson(queryOutput));
|
context.result(JsonUtils.toJson(queryOutput));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
|
Reference in New Issue
Block a user