Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-962

ignoreUndefined in find

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 2.2.26
    • Affects Version/s: 2.2.25
    • Component/s: None

      Hi,

      I've just spend an hour trying to debug a find query which has an undefined value.
      First problem is that logging the undefined value with JSON.stringify will not display anything (is there a debug util for this?). After I found out, I checked why our global ignoreUndefined = true was not working for the query.

      I found https://jira.mongodb.org/browse/NODE-563 which shows why the default ignore undefined mode was reverted to serialize to null again. I think this is exactly the right thing for the query part of updates, and to keep things consistent, find should behave the same way...
      But, there are no comments indicating this decision in https://github.com/mongodb/node-mongodb-native/blob/2.2/lib/collection.js#L179 which is unfortunate for a user that's debugging the code.
      It, imho, would be helpful to say something about these decisions in a comment in the code.

      To summarize:

      • comment in Collection.find why ignoreUndefined is not copied from this.s.options
      • a util function that can debug a js object that will be used as bson.

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            jaap@q42.nl Jaap Taal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: