precise work with mongoid

This commit is contained in:
Jan Prochazka
2021-12-07 21:29:31 +01:00
parent c113266095
commit 6bd48ca29f
8 changed files with 25 additions and 34 deletions

View File

@@ -8,6 +8,7 @@ export function getFilterValueExpression(value, dataType) {
if (isTypeDateTime(dataType)) return moment(value).format('YYYY-MM-DD HH:mm:ss');
if (value === true) return 'TRUE';
if (value === false) return 'FALSE';
if (value.$oid) return `ObjectId("${value.$oid}")`;
return `="${value}"`;
}

View File

@@ -28,16 +28,12 @@ const numberTestCondition = () => value => ({
],
});
const idRegex = /[('"]([0-9a-f]{24})['")]/;
const objectIdTestCondition = () => value => ({
$or: [
{
__placeholder__: {
$regex: `.*${value}.*`,
$options: 'i',
},
},
{
__placeholder__: { $oid: value },
__placeholder__: { $oid: value.match(idRegex)[1] },
},
],
});
@@ -78,7 +74,7 @@ const createParser = () => {
.map(Number)
.desc('number'),
objectid: () => token(P.regexp(/[0-9a-f]{24}/)).desc('ObjectId'),
objectid: () => token(P.regexp(/ObjectId\(['"]?[0-9a-f]{24}['"]?\)/)).desc('ObjectId'),
noQuotedString: () => P.regexp(/[^\s^,^'^"]+/).desc('string unquoted'),