Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-142

inserted 'undefined' field what I didn't insert while object inserting

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 0.4
    • None
    • windows, windows 7, 64bit

    Description

      hi, I'm using this library to connect to MongoDb in my project.
      I found strange thing when I insert some object into MongoDb.
      following is my test code and result.

      bson bs;
      bson_init(&bs);
      bson_append_start_object(&bs, "ObjName");
      bson_append_start_array(&bs, "ArrName");
      bson_append_start_object(&bs, "1");
      bson_append_string(&bs, "str1", "val1");
      bson_append_finish_object(&bs);
      bson_append_start_object(&bs, "2");
      bson_append_string(&bs, "str2", "val2");
      bson_append_finish_object(&bs);
      bson_append_start_object(&bs, "3");
      bson_append_string(&bs, "str3", "val3");
      bson_append_finish_object(&bs);
      bson_append_finish_array(&bs);
      bson_append_finish_object(&bs);
      bson_finish(&bs);
      bson_bool_t res = mongo_insert(
      conn,
      "MyTestDb.Test1",
      &bs
      );

      after success to insert, when I check that data in the mongo shell,
      they returns like following.

      show dbs;
      MyTestDb 0.078125GB
      local (empty)

      use MyTestDb
      switched to db MyTestDb
      show collections;
      Test1
      system.indexes

      db.Test1.findOne();
      {
      "_id" : ObjectId("4fbee85a1a374e84411c7eb4"),
      "ObjName" : {
      "ArrName" : [
      undefined,
      {
      "str1" : "val1"
      },
      {
      "str2" : "val2"
      },
      {
      "str3" : "val3"
      }
      ]
      }
      }
      there is 'undefined' field what I didn't insert.
      if this is already known issue, please let me know.
      I'll glad to receive any links, reply about this issue.

      thanks!

      -surym

      Attachments

        Activity

          People

            Unassigned Unassigned
            surym Seunghoon Park
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: