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

update push override the last element

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Won't Fix
    • Affects Version/s: 2.0.4
    • Fix Version/s: None
    • 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
    • Operating System:
      ALL

      Description

      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?

        Attachments

        1. 5908.js
          0.8 kB
        2. bug.lua
          0.3 kB

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: