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

rename isn't working

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Works as Designed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows, java 1.4 driver, mongo 1.3.3

      Description

      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);

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: