Skip to content

Commit

Permalink
Exposed set(name, value) for prepared queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydamage committed Aug 15, 2023
1 parent 879a0ca commit 6a561da
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ public PreparedQuery<T> bindValue(Object realValue) throws SchemaException {
return self();
}

/**
*
*
* @param name
* @param realValue
* @return
* @throws SchemaException
*/
public PreparedQuery<T> set(String name, Object realValue) throws SchemaException {
delegate.set(name, realValue);
return self();
}

/**
* Binds multiple values and returns final Typed Query which will contain filter.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,29 @@ public void test101EvaluatePreparedAxiomGivenNameModel() throws Exception {
//assertTrue("Object should be frozen", userTypeElaine.isImmutable());
}

@Test
public void test103EvaluatePreparedAxiomGivenNameUsingSetModel() throws Exception {
Task task = getTestTask();
var result = createOperationResult();
var prepared = PreparedQuery.parse(UserType.class, "givenName = :name and familyName = :family");

// Return read only result
prepared.operationOptionsBuilder().readOnly();

var query = prepared
.set("name", new PolyString("Elaine"))
.set("family", new PolyString("Marley"))
.build();

var objects = modelService.searchObjects(query, task, result);
assertEquals("Only one user should be found", 1, objects.size());
var only = objects.get(0);
assertEquals("User should be Elaine",userTypeElaine.getOid(),only.getOid());

// FIXME: Investigate why readOnly option does not work
//assertTrue("Object should be frozen", userTypeElaine.isImmutable());
}

@Test
public void test101EvaluatePreparedOrderingAndPagingModel() throws Exception {
Task task = getTestTask();
Expand Down

0 comments on commit 6a561da

Please sign in to comment.