<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:31 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-106] rename isn&apos;t working</title>
                <link>https://jira.mongodb.org/browse/JAVA-106</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;if I do:&lt;/p&gt;

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

&lt;p&gt;then I get:&lt;/p&gt;

&lt;p&gt;com.mongodb.MongoException: rename failed: &lt;/p&gt;
{ &quot;errmsg&quot; : &quot;assertion: source namespace does not exist&quot; , &quot;ok&quot; : 0.0}
&lt;p&gt;	at com.mongodb.DBCollection.rename(DBCollection.java:499)&lt;br/&gt;
	at com.refineddata.MongoDatabaseTest.testCreateExistsRenameDeleteCollection(MongoDatabaseTest.java:70)&lt;/p&gt;

&lt;p&gt;which doesn&apos;t seem appropriate as namespace should exist, the collection itself exists.&lt;/p&gt;

&lt;p&gt;If I save something in the code:&lt;/p&gt;

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

&lt;p&gt;the following is printed:&lt;/p&gt;

&lt;p&gt;  collection name = testCollection&lt;/p&gt;

&lt;p&gt;the following assertion fails (which shouldn&apos;t happen as no exception is thrown)&lt;br/&gt;
		assert collection.getName().equals(colNewName);&lt;/p&gt;
</description>
                <environment>Windows, java 1.4 driver, mongo 1.3.3</environment>
        <key id="11795">JAVA-106</key>
            <summary>rename isn&apos;t working</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="eliot">Eliot Horowitz</assignee>
                                    <reporter username="mwaschkowski">Mark Waschkowski</reporter>
                        <labels>
                    </labels>
                <created>Thu, 15 Apr 2010 16:37:10 +0000</created>
                <updated>Fri, 29 Oct 2010 02:49:57 +0000</updated>
                            <resolved>Tue, 18 May 2010 11:07:08 +0000</resolved>
                                    <version>2.0</version>
                                    <fixVersion>2.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="14310" author="mwaschkowski" created="Tue, 18 May 2010 11:51:37 +0000"  >&lt;p&gt;OK, thanks.&lt;/p&gt;</comment>
                            <comment id="14309" author="eliot" created="Tue, 18 May 2010 11:07:08 +0000"  >&lt;p&gt;rename() works at the db level, not the java level&lt;/p&gt;

&lt;p&gt;so in the first case, as far as the db is concerned, the collection doesn&apos;t exist&lt;/p&gt;

&lt;p&gt;in the 2nd case, the DBCollection object will never get changes.&lt;br/&gt;
you have to get the new one&lt;/p&gt;

&lt;p&gt;I changed rename so it returns the new DBCollection&lt;/p&gt;

&lt;p&gt;so you can do&lt;/p&gt;

&lt;p&gt;collection = collection.rename( &quot;newname&quot; )&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhd73:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14938</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>