-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Description
In getMongoData.js, any string that is parseable as an ISODate is converted into { $date : ... } in the output. This is wrong, I am in fact seeing fields that contain arbitrary alphanumeric codes being converted into $date notation. This is apparently done by this section in the code:
// For use in JSON.stringify to properly serialize known types
function jsonStringifyReplacer(k, v){
if (v instanceof ObjectId)
return { "$oid" : v.valueOf() };
if (v instanceof NumberLong)
return { "$numberLong" : longmangle(v) };
if (v instanceof NumberInt)
return v.toNumber();
// For ISODates; the $ check prevents recursion
if (typeof v === "string" && k.startsWith('$') == false){
try {
iso = ISODate(v);
return { "$date" : iso.valueOf() };
}
// Nothing to do here, we'll get the return at the end
catch(e) {}
}
return v;
}
Actually, I don't think it's right to parse strings into ISODates at all here, but I don't understand the overall logic well enough. Intuitively, I would think that v instanceof ISODate should suffice here.
Metadata
Metadata
Assignees
Labels
No labels