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

Querying objects with dot notation fails with error: TypeError: Cannot use 'in' operator to search for 'b' in null #891

Closed
olmuz opened this issue Aug 12, 2021 · 2 comments
Labels

Comments

@olmuz
Copy link

olmuz commented Aug 12, 2021

Querying objects with dot notation fails if there is an object with null value

Steps to reproduce:

const Loki = require('lokijs');
const db = new Loki();

const coll = db.addCollection('myCollection');

coll.insert({ a: { b: 'c' } });
coll.insert({ a: null });

coll.find({ 'a.b': 'c' });

Error:

/node_modules/lokijs/src/lokijs.js:418
      if (typeof root === 'object' && path in root) {
                                           ^

TypeError: Cannot use 'in' operator to search for 'b' in null

LokiJS version - 1.5.12

@blaky
Copy link
Contributor

blaky commented Sep 29, 2021

My PR should fix it: #896

@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants