mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix date on sqlite (#7774)
* fix date on sqlite * remove unused imports * rename KnexSpatial to KnexDate Co-authored-by: Jose Varela <joselcvarela@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { applyFunctionToColumnName } from './apply-function-to-column-name';
|
||||
import { getColumn } from './get-column';
|
||||
import { getRelationType } from './get-relation-type';
|
||||
import { getGeometryHelper } from '../database/helpers/geometry';
|
||||
import { getDateHelper } from '../database/helpers/date';
|
||||
|
||||
const generateAlias = customAlphabet('abcdefghijklmnopqrstuvwxyz', 5);
|
||||
|
||||
@@ -343,6 +344,22 @@ export function applyFilter(
|
||||
});
|
||||
}
|
||||
|
||||
const dateHelper = getDateHelper();
|
||||
|
||||
const [collection, field] = key.split('.');
|
||||
|
||||
if (collection in schema.collections && field in schema.collections[collection].fields) {
|
||||
const type = schema.collections[collection].fields[field].type;
|
||||
|
||||
if (['date', 'dateTime', 'time', 'timestamp'].includes(type)) {
|
||||
if (Array.isArray(compareValue)) {
|
||||
compareValue = compareValue.map((val) => dateHelper.parseDate(val));
|
||||
} else {
|
||||
compareValue = dateHelper.parseDate(compareValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The following fields however, require a value to be run. If no value is passed, we
|
||||
// ignore them. This allows easier use in GraphQL, where you wouldn't be able to
|
||||
// conditionally build out your filter structure (#4471)
|
||||
|
||||
Reference in New Issue
Block a user