Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-2749

Collection inaccessable via db.foo.find(); if you save {toString : {}}

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.4.0-rc2
    • Affects Version/s: 1.6.5
    • Component/s: JavaScript
    • None
    • Environment:
      OSX, MongoDB 1.6.5, although I imagine it's a cross platform bug
    • Fully Compatible
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Steps to reproduce in the shell:

      db.bug.save({toString : {} });
      db.bug.find();

      Resulting error message: "TypeError: x.toString is not a function"

      You don't get any results and the only way to fix it in the shell is either db.bug.remove(); or db.bug.drop();

      I know it's a stupid object to save, but a bug in my code saved an object with {toString : {} } and I ran into this.

      Throw this in there:

      (typeof(x.toString) === 'function') ? x.toString() : x

      Thanks.

            Assignee:
            Unassigned Unassigned
            Reporter:
            sktayloriii Kendrick Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: