Skip to content

Commit

Permalink
Feat: no exception if dateformat and no date provided
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbet committed Feb 26, 2025
1 parent c0fc153 commit 8b79daf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ public void applyFilter(Filter filter, FluidSearchService fluidSearch) throws Ar
if (filter.f != null && !filter.f.isEmpty()) {
CollectionReference collectionReference = fluidSearch.getCollectionReference();
if (!filterFHasDateQuery(filter, collectionReference) && !StringUtil.isNullOrEmpty(filter.dateformat)) {
throw new BadRequestException("dateformat is specified but no date field is queried in f filter (gt, lt, gte, lte or range operations)");
filter.dateformat = null;
LOGGER.warn("dateformat is specified but no date field is queried in f filter (gt, lt, gte, lte or range operations)");
}
for (MultiValueFilter<Expression> f : filter.f) {
fluidSearch = fluidSearch.filter(f, filter.dateformat, filter.righthand);
Expand All @@ -169,7 +170,8 @@ public void applyPartitionFilter(List<Filter> filters, FluidSearchService fluidS
if (f.f != null && !f.f.isEmpty()) {
CollectionReference collectionReference = fluidSearch.getCollectionReference();
if (!filterFHasDateQuery(f, collectionReference) && !StringUtil.isNullOrEmpty(f.dateformat)) {
throw new BadRequestException("dateformat is specified but no date field is queried in f filter (gt, lt, gte, lte or range operations)");
filter.dateformat = null;
LOGGER.warn("dateformat is specified but no date field is queried in f filter (gt, lt, gte, lte or range operations)");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2083,14 +2083,6 @@ public void testInvalidFilterParameters() throws Exception {
handleInvalidParameters(givenFilterableRequestParams().param("f", request.filter.f.get(0).get(0).toString())
.param("dateformat", request.filter.dateformat).when().get(getUrlPath("geodata")).then());
handleInvalidParameters(header(request.filter));

// DATEFORMAT : format set when no date field is queried
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.like, "Architect")));
request.filter.dateformat = "dd-MM-yyyy";
handleInvalidParameters(post(request));
handleInvalidParameters(givenFilterableRequestParams().param("f", request.filter.f.get(0).get(0).toString())
.param("dateformat", request.filter.dateformat).when().get(getUrlPath("geodata")).then());
handleInvalidParameters(header(request.filter));
}

@Test
Expand Down

0 comments on commit 8b79daf

Please sign in to comment.