Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-106

rename isn't working

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.0
    • Affects Version/s: 2.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows, java 1.4 driver, mongo 1.3.3

      if I do:

      db.requestStart();
      db.setWriteConcern(WriteConcern.STRICT);
      String colName = "testCollection";
      DBCollection collection = db.getCollection(colName);
      //mongodb.save(getTestObject(), colName);
      //long size = collection.getCount();
      //assert size == 1;
      String colNewName = "testCollection2";
      collection.rename(colNewName);
      System.out.println("collection name = " + collection.getName());
      assert collection.getName().equals(colNewName);
      db.requestDone();

      then I get:

      com.mongodb.MongoException: rename failed:

      { "errmsg" : "assertion: source namespace does not exist" , "ok" : 0.0}

      at com.mongodb.DBCollection.rename(DBCollection.java:499)
      at com.refineddata.MongoDatabaseTest.testCreateExistsRenameDeleteCollection(MongoDatabaseTest.java:70)

      which doesn't seem appropriate as namespace should exist, the collection itself exists.

      If I save something in the code:

      db.requestStart();
      db.setWriteConcern(WriteConcern.STRICT);
      String colName = "testCollection";
      DBCollection collection = db.getCollection(colName);
      mongodb.save(getTestObject(), colName);
      long size = collection.getCount();
      assert size == 1;
      String colNewName = "testCollection2";
      collection.rename(colNewName);
      System.out.println("collection name = " + collection.getName());
      assert collection.getName().equals(colNewName);
      db.requestDone();

      the following is printed:

      collection name = testCollection

      the following assertion fails (which shouldn't happen as no exception is thrown)
      assert collection.getName().equals(colNewName);

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            mwaschkowski Mark Waschkowski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: