You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
drmirror
changed the title
Wrong handling of strings that look like dates
getMongoData.js – Wrong handling of strings that look like dates
Nov 3, 2016
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: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.The text was updated successfully, but these errors were encountered: