Add LIKE criteria operator; more api endpoints to understand versions, get swagger json; more field name mapping

This commit is contained in:
2023-03-24 10:20:26 -05:00
parent 74cf24a00e
commit 17d4c81cc3
11 changed files with 374 additions and 43 deletions

View File

@ -601,6 +601,18 @@ public abstract class AbstractRDBMSAction implements QActionInterface
}
break;
}
case LIKE:
{
clause += " LIKE ?";
expectedNoOfParams = 1;
break;
}
case NOT_LIKE:
{
clause += " NOT LIKE ?";
expectedNoOfParams = 1;
break;
}
case STARTS_WITH:
{
clause += " LIKE ?";

View File

@ -213,6 +213,46 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
/*******************************************************************************
**
*******************************************************************************/
@Test
public void testLike() throws QException
{
QueryInput queryInput = initQueryRequest();
queryInput.setFilter(new QQueryFilter()
.withCriteria(new QFilterCriteria()
.withFieldName("email")
.withOperator(QCriteriaOperator.LIKE)
.withValues(List.of("%kelk%")))
);
QueryOutput queryOutput = new RDBMSQueryAction().execute(queryInput);
assertEquals(1, queryOutput.getRecords().size(), "Expected # of rows");
Assertions.assertTrue(queryOutput.getRecords().stream().allMatch(r -> r.getValueString("email").matches(".*kelkhoff.*")), "Should find matching email address");
}
/*******************************************************************************
**
*******************************************************************************/
@Test
public void testNotLike() throws QException
{
QueryInput queryInput = initQueryRequest();
queryInput.setFilter(new QQueryFilter()
.withCriteria(new QFilterCriteria()
.withFieldName("email")
.withOperator(QCriteriaOperator.NOT_LIKE)
.withValues(List.of("%kelk%")))
);
QueryOutput queryOutput = new RDBMSQueryAction().execute(queryInput);
assertEquals(4, queryOutput.getRecords().size(), "Expected # of rows");
Assertions.assertTrue(queryOutput.getRecords().stream().noneMatch(r -> r.getValueString("email").matches(".*kelkhoff.*")), "Should find matching email address");
}
/*******************************************************************************
**
*******************************************************************************/