Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-483

DBRef and $code types not preserved in import/export roundtrip

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8.0-rc5
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • 2014 Last MCI Iteration

      (function() {
          jsTest.log('Testing running import with various data types');
      
          var testDoc = {
            _id : ObjectId(),
            a : BinData(0,"e8MEnzZoFyMmD7WSHdNrFJyEk8M="),
            b : DBRef("blah", "foo"),
            d : "this is a string",
            e : ["this is an ", 2, 23.5, "array with various types in it"],
            f : {"this is": "an embedded doc"},
            g : function(){print("hey sup")},
            h : null,
            i : true,
            j : false,
            k : NumberLong(10000),
            l : MinKey(),
            k : MaxKey(),
          }
      
      
          var toolTest = new ToolTest('import');
          var db1 = toolTest.startDB('foo');
      
          //Make a dummy file to import by writing a test collection and exporting it
          assert.eq( 0 , db1.c.count() , "setup1" );
          db1.c.save(testDoc)
          toolTest.runTool( "export" , "--out" , toolTest.extFile , "-d" , toolTest.baseName , "-c" , db1.c.getName());
      
          var ret = toolTest.runTool("import", "--file",toolTest.extFile, "--db", "imported", "--collection", "testcoll2")
          var postImportDoc = db1.c.getDB().getSiblingDB("imported").testcoll2.findOne()
      
      
          printjson(postImportDoc)
      
          docKeys = Object.keys(testDoc)
          for(var i=0;i<docKeys.length;i++){
            jsTest.log("checking field", docKeys[i])
            assert.eq(testDoc[docKeys[i]], postImportDoc[docKeys[i]], "imported field " + docKeys[i] + " does not match original")
          }
      
      
          toolTest.stop();
      }());
      

            Assignee:
            mikeo@mongodb.com Michael O'Brien
            Reporter:
            mikeo@mongodb.com Michael O'Brien
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: