<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:53:24 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-927] &quot;deep copy&quot; for Document</title>
                <link>https://jira.mongodb.org/browse/JAVA-927</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Can you please enhance API to provide `deep copy` for a Document object.&lt;/p&gt;

&lt;p&gt;It was possible in version 2.x of MongoDB Java driver via this simple hack (Scala code):&lt;/p&gt;

&lt;p&gt;dbo.asInstanceOf&lt;span class=&quot;error&quot;&gt;&amp;#91;BasicDBObject&amp;#93;&lt;/span&gt;.copy.asInstanceOf&lt;span class=&quot;error&quot;&gt;&amp;#91;DBObject&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;I&apos;m using it in &quot;Subset&quot; library: &lt;a href=&quot;https://github.com/osinka/subset2/blob/master/src/main/scala/DBO.scala#L97&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/osinka/subset2/blob/master/src/main/scala/DBO.scala#L97&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="85901">JAVA-927</key>
            <summary>&quot;deep copy&quot; for Document</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="alaz">Alexander Azarov</reporter>
                        <labels>
                    </labels>
                <created>Wed, 14 Aug 2013 12:02:35 +0000</created>
                <updated>Tue, 7 Mar 2017 17:50:51 +0000</updated>
                            <resolved>Wed, 21 Sep 2016 21:19:12 +0000</resolved>
                                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="773066" author="jeff.yemin" created="Wed, 26 Nov 2014 02:52:50 +0000"  >&lt;p&gt;Hi Jon,&lt;/p&gt;

&lt;p&gt;True, though we would need a different name than copy.  If you&apos;d like to suggest an alternative, please open a new issue for it, as this one is about the new Document class in the 3.0.x branch, not about BasicDBObject.&lt;/p&gt;


&lt;p&gt;Thanks,&lt;br/&gt;
Jeff&lt;/p&gt;</comment>
                            <comment id="773014" author="ccjon" created="Wed, 26 Nov 2014 00:48:36 +0000"  >&lt;p&gt;Your right, not much you can do... but you can create a new signature and deprecate the old one... it&apos;s got a long tail, but it&apos;s something.&lt;/p&gt;</comment>
                            <comment id="772021" author="jeff.yemin" created="Tue, 25 Nov 2014 04:21:41 +0000"  >&lt;p&gt;There is no good reason that I can see for BasicDBObject.copy to return Object, but since changing it will break binary compatibility we are kind of stuck with it.&lt;/p&gt;</comment>
                            <comment id="771792" author="ccjon" created="Mon, 24 Nov 2014 22:22:39 +0000"  >&lt;p&gt;The comment for copy() is:&lt;br/&gt;
 /**&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Creates a new instance which is a copy of this BasicDBObject.&lt;br/&gt;
*&lt;/li&gt;
	&lt;li&gt;@return a BasicDBObject with exactly the same values as this instance.&lt;br/&gt;
*/&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;But it returns an java.lang.Object ... is that something to do with the the Map having Object as a value type, or should I create a ticket?&lt;/p&gt;</comment>
                            <comment id="615762" author="jeff.yemin" created="Tue, 10 Jun 2014 16:50:57 +0000"  >&lt;p&gt;In the general case I don&apos;t think this can be done properly.  Since Document is a Map&amp;lt;String, Object&amp;gt; we can&apos;t know for sure that every value in the Map is deep-copyable.&lt;/p&gt;

&lt;p&gt;That said, we are working on a new class called BsonDocument that has a closed type system of Map&amp;lt;String, BsonValue&amp;gt;.  This class could easily support a deep copy via constructor:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; BsonDocument(BsonDocument from)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
</comment>
                            <comment id="578018" author="ross@10gen.com" created="Fri, 9 May 2014 10:30:09 +0000"  >&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/pull/195&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/pull/195&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="407713" author="abrightwell" created="Tue, 20 Aug 2013 21:35:08 +0000"  >&lt;p&gt;From my testing and inspection of the code, it would appear that this method and functionality is already available in both BasicDBObject and BasicDBList as of &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/7a3a2364415f42422404b67973fd2ddd41dd3465&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;7a3a2364&lt;/a&gt;.  It would appear that this is a &quot;deep copy&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|hrgaef:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>8589</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="161">Sprint 2 - May 5 - May 23</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>