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

update push override the last element

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 2.0.4
    • Component/s: Internal Code, Write Ops
    • Labels:
    • Environment:
      ubuntu 12.04

      Linux simon-1 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux
    • ALL

      I wrote a lua driver(https://github.com/bigplum/lua-resty-mongol) based on openresty(ngx_lua) project. There is an issue: http://forum.nginx.org/read.php?2,226716,226744#msg-226744

      1. use lua-resty-mongol inster an embeded array, mongo shell shows ok.
      The "undefined" value comes from that lua table index beginning from 1.

      local t = {}
      table.insert(t,

      {a = "aa"}

      )
      table.insert(t,

      {b = "bb"}

      )
      r, err = col:insert(name="dog",n="10",tab=t, nil, true)

      > db.test.find()
      { "_id" : ObjectId("4fbc97e10853d55c767302f8"), "tab" : [ undefined,

      { "a" : "aa" }

      ,

      { "b" : "bb" }

      ], "name" : "dog", "n" : "10" }

      2. use mongo shell update to push a new value into tab, the last element of tab is overrided.

      > db.test.update(

      {name:"dog"}

      , {$push:{tab:"a5"}})
      > db.test.find()
      { "_id" : ObjectId("4fbc97e10853d55c767302f8"), "n" : "10", "name" : "dog", "tab" : [ undefined,

      { "a" : "aa" }

      , "a5" ] }

      So, is this bug is related with the "undefined" value?

        1. 5908.js
          0.8 kB
          siddharth.singh@10gen.com
        2. bug.lua
          0.3 kB
          siddharth.singh@10gen.com

            Assignee:
            benjamin.becker Ben Becker
            Reporter:
            bigplum Simon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: