mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
precise work with mongoid
This commit is contained in:
@@ -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}"`;
|
||||
}
|
||||
|
||||
|
||||
@@ -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'),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user