Fix data provider filtering on datetime fields

This commit is contained in:
Andrew Kingston 2021-07-06 12:01:01 +01:00
parent 83a91a8943
commit 4bc1938966
1 changed files with 5 additions and 2 deletions

View File

@ -13,9 +13,12 @@ export const buildLuceneQuery = filter => {
notEmpty: {}, notEmpty: {},
} }
if (Array.isArray(filter)) { if (Array.isArray(filter)) {
// Build up proper range filters
filter.forEach(expression => { filter.forEach(expression => {
const { operator, field, type, value } = expression let { operator, field, type, value } = expression
// Ensure date fields are transformed into ISO strings
if (type === "datetime" && value) {
value = new Date(value).toISOString()
}
if (operator.startsWith("range")) { if (operator.startsWith("range")) {
if (!query.range[field]) { if (!query.range[field]) {
query.range[field] = { query.range[field] = {