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

db.collection.save() with documents that contain functions doubling up function names

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: JavaScript
    • Labels:
      None
    • Environment:
      Win 7 64 bit, Mongo 2.0
    • Windows

      I suppose this pretty much should speak for its self. At first I thought just the internal function name doubled up, but the custom name would remain when __toString() is called in php. But what it does is take the full internal function name, then re-assign a prefix to it, returning the entire pre-update name as the new function name. Attached is a screenshot, before and after the update I've pasted below.

      > a = db.validation.findOne(

      {name:'cellPhone'}

      )
      {
      "_id" : ObjectId("4eadb65ba653908619848869"),
      "name" : "cellPhone",
      "error" : "At least one phone number must be entered",
      "code" : function cf_31_f_cf_28f() {},
      "errorGroup" : "cellPhone"
      }
      > a.errorGroup = 'phone'
      phone
      > db.validation.save(a)
      > a = db.validation.findOne(

      {name:'cellPhone'}

      )
      {
      "_id" : ObjectId("4eadb65ba653908619848869"),
      "name" : "cellPhone",
      "error" : "At least one phone number must be entered",
      "code" : function cf_32_f_cf_31_f_cf_28f() {
      },
      "errorGroup" : "phone"
      }
      > a.code = function code(a){}
      function code(a) {
      }
      > db.validation.save(a)
      > a = db.validation.findOne(

      {name:'cellPhone'}

      )
      {
      "_id" : ObjectId("4eadb65ba653908619848869"),
      "name" : "cellPhone",
      "error" : "At least one phone number must be entered",
      "code" : function cf_33_f_code(a) {},
      "errorGroup" : "phone"
      }
      > a.errorGroup = 'phone1'
      phone1
      > db.validation.save(a)
      > a = db.validation.findOne(

      {name:'cellPhone'}

      )
      {
      "_id" : ObjectId("4eadb65ba653908619848869"),
      "name" : "cellPhone",
      "error" : "At least one phone number must be entered",
      "code" : function cf_34_f_cf_33_f_code(a) {},
      "errorGroup" : "phone1"
      }
      > b = db.validation.findOne(

      {name:'businessPhone'}

      )
      {
      "_id" : ObjectId("4eb0036aa65390861984886a"),
      "name" : "businessPhone",
      "error" : "At least one phone number must be entered",
      "code" : function cf_35_f_cf_30_f_cf_28f() {},
      "errorGroup" : "phone"
      }
      > b.run = function(a){}
      function (a) {
      }
      > db.validation.save(b)
      > b = db.validation.findOne(

      {name:'businessPhone'}

      )
      {
      "_id" : ObjectId("4eb0036aa65390861984886a"),
      "name" : "businessPhone",
      "error" : "At least one phone number must be entered",
      "code" : function cf_36_f_cf_35_f_cf_30_f_cf_28f() {},
      "errorGroup" : "phone",
      "run" : function cf_37f(a) {
      }
      }
      > delete b.run
      true
      > db.validation.save(b)
      > b = db.validation.findOne(

      {name:'businessPhone'}

      )
      {
      "_id" : ObjectId("4eb0036aa65390861984886a"),
      "name" : "businessPhone",
      "error" : "At least one phone number must be entered",
      "code" : function cf_38_f_cf_36_f_cf_35_f_cf_30_f_cf_28f() {},
      "errorGroup" : "phone"
      }

        1. mongodbbug.png
          40 kB
          Kavi Siegel

            Assignee:
            brandon Brandon Diamond
            Reporter:
            kavisiegel Kavi Siegel
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: