Compare commits
3 Commits
ecfb111551
...
b7aa544a2f
Author | SHA1 | Date |
---|---|---|
Luke deGruchy | b7aa544a2f | |
Luke deGruchy | 3c776ab363 | |
Luke deGruchy | a0e41439a6 |
|
@ -2675,6 +2675,7 @@ public class QueryStack {
|
|||
}
|
||||
}
|
||||
|
||||
// LUKETODO: we already have the HASH_SYS WHERE SQL here and nothing else
|
||||
return toAndPredicate(andPredicates);
|
||||
}
|
||||
|
||||
|
|
|
@ -297,11 +297,14 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
|
|||
continue;
|
||||
}
|
||||
List<List<IQueryParameterType>> andOrParams = myParams.get(nextParamName);
|
||||
Condition predicate = theQueryStack.searchForIdsWithAndOr(with().setResourceName(myResourceName)
|
||||
final QueryStack.SearchForIdsParams searchForIdsParams = with().setResourceName(myResourceName)
|
||||
.setParamName(nextParamName)
|
||||
.setAndOrParams(andOrParams)
|
||||
.setRequest(theRequest)
|
||||
.setRequestPartitionId(myRequestPartitionId));
|
||||
// .setSourceJoinColumn(theQueryStack.) ????
|
||||
.setRequestPartitionId(myRequestPartitionId);
|
||||
// LUKETODO: setResourceName appears NOT to work here?!?!?!??!??!?!
|
||||
Condition predicate = theQueryStack.searchForIdsWithAndOr(searchForIdsParams);
|
||||
if (predicate != null) {
|
||||
theSearchSqlBuilder.addPredicate(predicate);
|
||||
}
|
||||
|
@ -677,14 +680,26 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
|
|||
|
||||
// If we haven't added any predicates yet, we're doing a search for all resources. Make sure we add the
|
||||
// partition ID predicate in that case.
|
||||
if (!sqlBuilder.haveAtLeastOnePredicate()) {
|
||||
Condition partitionIdPredicate = sqlBuilder
|
||||
.getOrCreateResourceTablePredicateBuilder()
|
||||
.createPartitionIdPredicate(myRequestPartitionId);
|
||||
// LUKETODO: commenting this out seems to fix the problem
|
||||
// if (!sqlBuilder.haveAtLeastOnePredicate()) {
|
||||
// LUKETODO: this is where we add the RES_TYPE clause
|
||||
// LUKETODO: we skip this in the failing case because there's no predicate??????
|
||||
Condition partitionIdPredicate =
|
||||
sqlBuilder.getOrCreateResourceTablePredicateBuilder().createPartitionIdPredicate(myRequestPartitionId);
|
||||
if (partitionIdPredicate != null) {
|
||||
sqlBuilder.addPredicate(partitionIdPredicate);
|
||||
}
|
||||
}
|
||||
// }
|
||||
// // If we haven't added any predicates yet, we're doing a search for all resources. Make sure we add the
|
||||
|
||||
// // partition ID predicate in that case.
|
||||
// if (!sqlBuilder.haveAtLeastOnePredicate()) {
|
||||
// Condition partitionIdPredicate =
|
||||
// sqlBuilder.getOrCreateResourceTablePredicateBuilder().createPartitionIdPredicate(myRequestPartitionId);
|
||||
// if (partitionIdPredicate != null) {
|
||||
// sqlBuilder.addPredicate(partitionIdPredicate);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Add PID list predicate for full text search and/or lastn operation
|
||||
addPidListPredicate(thePidList, sqlBuilder);
|
||||
|
@ -743,6 +758,7 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
|
|||
private void executeSearch(
|
||||
Integer theOffset, List<ISearchQueryExecutor> theSearchQueryExecutors, SearchQueryBuilder sqlBuilder) {
|
||||
GeneratedSql generatedSql = sqlBuilder.generate(theOffset, myMaxResultsToFetch);
|
||||
ourLog.info("6086: generatedSql:\n{}\nparams:\n{}", generatedSql.getSql(), generatedSql.getBindVariables());
|
||||
if (!generatedSql.isMatchNothing()) {
|
||||
SearchQueryExecutor executor =
|
||||
mySqlBuilderFactory.newSearchQueryExecutor(generatedSql, myMaxResultsToFetch);
|
||||
|
|
|
@ -646,6 +646,7 @@ public class SearchQueryBuilder {
|
|||
ResourceTablePredicateBuilder resourceTable = mySqlBuilderFactory.resourceTable(this);
|
||||
addTable(resourceTable, null);
|
||||
if (theIncludeResourceTypeAndNonDeletedFlag) {
|
||||
// LUKETODO: this is where we add the RES_TYPE clause
|
||||
Condition typeAndDeletionPredicate = resourceTable.createResourceTypeAndNonDeletedPredicates();
|
||||
addPredicate(typeAndDeletionPredicate);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package ca.uhn.fhir.jpa.dao.r4;
|
||||
|
||||
import ca.uhn.fhir.batch2.jobs.step.ResourceIdListStep;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.interceptor.api.Hook;
|
||||
import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc;
|
||||
import ca.uhn.fhir.jpa.dao.TestDaoSearch;
|
||||
import ca.uhn.fhir.jpa.test.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.test.config.TestHSearchAddInConfig;
|
||||
|
@ -30,7 +33,10 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution
|
|||
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||
|
@ -66,6 +72,8 @@ public class FhirResourceDaoR4QuerySandbox extends BaseJpaTest {
|
|||
DaoTestDataBuilder myDataBuilder;
|
||||
@Autowired
|
||||
TestDaoSearch myTestDaoSearch;
|
||||
@Autowired
|
||||
IBatch2DaoSvc myBatch2DaoSvc;
|
||||
|
||||
@Override
|
||||
protected PlatformTransactionManager getTxManager() {
|
||||
|
@ -162,6 +170,42 @@ public class FhirResourceDaoR4QuerySandbox extends BaseJpaTest {
|
|||
assertTrue(actualIds.containsAll(List.of(id1, id2, id3)));
|
||||
}
|
||||
|
||||
// LUKETODO: consider @Nested class
|
||||
@Test
|
||||
void testDeleteExpunge1() {
|
||||
// SearchParameterMap[params={event=[[TokenParam[system=http://terminology.hl7.org/CodeSystem/v2-0003,value=], TokenParam[system=https://harris-chr.com/fhir/CodeSystem/arc-interface-trigger,value=]]]}]
|
||||
// MessageHeader?event=http://terminology.hl7.org/CodeSystem/v2-0003|,https://harris-chr.com/fhir/CodeSystem/arc-interface-trigger|&_lastUpdated=ge2023-09-17T00:00:00.000000Z&_lastUpdated=le2025-09-23T23:59:59.999999Z&_expunge=true
|
||||
// myTestDaoSearch.searchForResources("MessageHeader?event=http://terminology.hl7.org/CodeSystem/v2-0003|,https://harris-chr.com/fhir/CodeSystem/arc-interface-trigger|&_lastUpdated=ge2023-09-17T00:00:00.000000Z&_lastUpdated=le2025-09-23T23:59:59.999999Z&_expunge=true");
|
||||
final LocalDateTime startDateTime = LocalDateTime.now().minusDays(2);
|
||||
final Date startDate = Date.from(startDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
final LocalDateTime endDateTime = LocalDateTime.now().minusDays(1);
|
||||
final Date endDate = Date.from(endDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
|
||||
myBatch2DaoSvc.fetchResourceIdStream(startDate, endDate, RequestPartitionId.allPartitions(), "MessageHeader?event=http://terminology.hl7.org/CodeSystem/v2-0003|,https://harris-chr.com/fhir/CodeSystem/arc-interface-trigger|&_lastUpdated=ge2023-09-17T00:00:00.000000Z&_lastUpdated=le2025-09-23T23:59:59.999999Z&_expunge=true")
|
||||
.visitStreamNoResult(x -> {
|
||||
var z = x.toList();
|
||||
});
|
||||
final List<String> queries = myCapturedQueries.stream().toList();
|
||||
|
||||
ourLog.info("queries: {}", queries);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteExpunge2() {
|
||||
final LocalDateTime startDateTime = LocalDateTime.now().minusDays(2);
|
||||
final Date startDate = Date.from(startDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
final LocalDateTime endDateTime = LocalDateTime.now().minusDays(1);
|
||||
final Date endDate = Date.from(endDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
|
||||
myBatch2DaoSvc.fetchResourceIdStream(startDate, endDate, RequestPartitionId.allPartitions(), "MessageHeader?_lastUpdated=ge2023-09-17T00:00:00.000000Z&_lastUpdated=le2025-09-23T23:59:59.999999Z&_expunge=true")
|
||||
.visitStreamNoResult(x -> {
|
||||
var z = x.toList();
|
||||
});
|
||||
final List<String> queries = myCapturedQueries.stream().toList();
|
||||
|
||||
ourLog.info("queries: {}", queries);
|
||||
}
|
||||
|
||||
public static final class TestDirtiesContextTestExecutionListener extends DirtiesContextTestExecutionListener {
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue