Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectID matching on array broken in 5.x line, fixed in 6.x line #659

Open
patrickdk77 opened this issue Mar 8, 2022 · 0 comments
Open
Labels
bug v5.x Affects v5.x

Comments

@patrickdk77
Copy link

Steps to reproduce

Install 5.6.0, pass an array of ObjectId's in a query such as:
app.models.catalog.find({}, function(err,catalogs) {
let catalogIds=[];
for(let i=catalogs.length; i>0; i--) catalogIds.push(catalogs[i-1].id);
app.models.registry.find({where:{ catalogId: { in: catalogIds}}}, function()...

Current Behavior

typeError: v.match does not exist

Expected Behavior

successful query lookup

Link to reproduction sandbox

Additional information

@@ -2167,7 +2169,7 @@
if (!propDef) return false;

if ((typeof value === 'string' && value.match(ObjectIdValueRegex)) ||

  • (Array.isArray(value) && value.every((v) => v.match(ObjectIdValueRegex)))) {
  • (Array.isArray(value) && value.every((v) => typeof v === 'string' && v.match(ObjectIdValueRegex)))) {
    if (isStoredAsObjectID(propDef)) return true;
    else return !isStrictObjectIDCoercionEnabled(modelCtor, options);
    } else if (value instanceof mongodb.ObjectID) {

Related Issues

See Reporting Issues for more tips on writing good issues

@patrickdk77 patrickdk77 added the bug label Mar 8, 2022
@achrinza achrinza added the v5.x Affects v5.x label Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v5.x Affects v5.x
Projects
None yet
Development

No branches or pull requests

2 participants