<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:37:22 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>[CSHARP-622] Add [MongoOldName(&quot;OldName&quot;)] attribute &amp; updates to Linq provider</title>
                <link>https://jira.mongodb.org/browse/CSHARP-622</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;One common use-case for attempting migrations is for things like renaming fields. If you rename a property from `OldName` to `NewName`, the existing documents won&apos;t have been updated so `NewName` will typically be null.&lt;/p&gt;

&lt;p&gt;The defensive coding argument is to use &lt;span class=&quot;error&quot;&gt;&amp;#91;MongoExtraElements&amp;#93;&lt;/span&gt; attribute to fill a dictionary and update your CLR object accordingly.&lt;/p&gt;

&lt;p&gt;The issue with the defensive coding strategy is that you can&apos;t query against `NewName` until the object has been updated &amp;amp; saved. Most documents may take a while before they&apos;re upgraded, and some may never be upgraded. In the meantime, we would have to sprinkle all of our queries with `Query.OR(Query.EQ(&quot;NewName&quot;, &quot;foo&quot;), Query.EQ(&quot;OldName&quot;, &quot;foo&quot;))`. &lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;I propose that we solve this querying issue by updating the Linq driver to automatically do (x.NewName == &quot;foo&quot; || x.OldName == &quot;foo&quot;) whenever a field has been renamed. To rename a field, I propose a &lt;span class=&quot;error&quot;&gt;&amp;#91;MongoOldName(&amp;lt;old-name&amp;gt;)&amp;#93;&lt;/span&gt; attribute.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;I believe that this case of renaming a field is very common. Due to the nature of Mongo, I also think it&apos;s best to implement this at the driver level.&lt;/p&gt;</description>
                <environment></environment>
        <key id="54944">CSHARP-622</key>
            <summary>Add [MongoOldName(&quot;OldName&quot;)] attribute &amp; updates to Linq provider</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="3">Duplicate</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="tkellogg">Tim Kellogg</reporter>
                        <labels>
                            <label>linq</label>
                            <label>migration</label>
                    </labels>
                <created>Wed, 31 Oct 2012 21:13:48 +0000</created>
                <updated>Mon, 11 Mar 2019 18:45:02 +0000</updated>
                            <resolved>Mon, 6 Apr 2015 21:05:53 +0000</resolved>
                                    <version>1.6.1</version>
                                                                        <votes>1</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="220739" author="tkellogg" created="Thu, 20 Dec 2012 22:33:01 +0000"  >&lt;p&gt;I did some thinking about a more complete implementation than I suggested here. I wrote a demonstration implementation of the sort of changes I&#8217;d like to see in the driver. Aside from those changes, I&#8217;d like to see migrations implemented outside the core driver DLL using those hooks.&lt;/p&gt;

&lt;p&gt;The migration-spike branch of my fork is at &lt;a href=&quot;https://github.com/tkellogg/mongo-csharp-driver/tree/migration-spike&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/tkellogg/mongo-csharp-driver/tree/migration-spike&lt;/a&gt;. The main type you should be paying attention to is IBsonSerializationEventHook (&lt;a href=&quot;https://github.com/tkellogg/mongo-csharp-driver/blob/migration-spike/Bson/Serialization/IBsonSerializationEventHook.cs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/tkellogg/mongo-csharp-driver/blob/migration-spike/Bson/Serialization/IBsonSerializationEventHook.cs&lt;/a&gt;) and where it ties in to BsonClassMapSerializer.&lt;/p&gt;

&lt;p&gt;I still haven&#8217;t written any interfaces for processing queries for migrations. I just wanted to see if it was plausible. In our own (proprietary) code I implemented some migrations for specific purposes (rename a specific property, change type of a specific property, nothing generic). I can&#8217;t share that code, but it was only enough to prove the concept anyway.&lt;/p&gt;

&lt;p&gt;I&#8217;m writing all this to see if you like the direction. I think we should discuss this in an open forum before investing too much effort. I like the idea of keeping the driver changes as small as possible and starting an external project for migrations, so they can be optional. I imagine that we won&#8217;t get the API right the first time, so this is an incremental approach that leaves room for alternative migration APIs.&lt;/p&gt;</comment>
                            <comment id="181966" author="tkellogg" created="Fri, 2 Nov 2012 16:52:08 +0000"  >&lt;p&gt;Thinking about this, it doesn&apos;t &lt;em&gt;entirely&lt;/em&gt; solve the upgrade problem for field renames. For instance, consider a cloud with two web servers (A &amp;amp; B). After you upgrade server A to rename &quot;OldName&quot; to &quot;NewName&quot;, queries from server B will be invalid until it&apos;s also upgraded; because it&apos;s queries will only know to look at &quot;OldName&quot;.&lt;/p&gt;

&lt;p&gt;With the above solution, if I wanted assurances that I didn&apos;t have any invalid states I would have to do a complicated switcheroo:&lt;/p&gt;

&lt;p&gt; 1. pre-plan the rename by placing an &lt;span class=&quot;error&quot;&gt;&amp;#91;MongoOldName(&amp;quot;NewName&amp;quot;)&amp;#93;&lt;/span&gt; attribute&lt;br/&gt;
 2. Deploy to both servers (A &amp;amp; B)&lt;br/&gt;
 3. Edit the code again to rename x.OldName to x.NewName and change the attribute to read &lt;span class=&quot;error&quot;&gt;&amp;#91;MongoOldName(&amp;quot;OldName&amp;quot;)&amp;#93;&lt;/span&gt;&lt;br/&gt;
 4. Redeploy to both servers. This time, when A comes up, changes it makes won&apos;t affect B negatively.&lt;/p&gt;

&lt;p&gt;This is a complicated way to make these guarantees. One route to consider is adding configuration file support for this specific scenario (since config files don&apos;t require a recompile and often no restart). Regardless, I hope there&apos;s an even better answer that can be more automated.&lt;/p&gt;</comment>
                            <comment id="181200" author="craiggwilson" created="Wed, 31 Oct 2012 22:26:38 +0000"  >&lt;p&gt;I&apos;m not sure it&apos;s a lot of work, just we need to make sure it&apos;s done correctly, so definitely would like to discuss before going off and doing it.  I think it&apos;s just a matter of putting the hooks in the right places, so likely some rearchitecture would be needed.  Thanks for volunteering and let us know if this is something you want to tackle and when.  We&apos;ll make sure we get on a phone call or something to discuss when you are ready.&lt;/p&gt;</comment>
                            <comment id="181192" author="tkellogg" created="Wed, 31 Oct 2012 22:05:05 +0000"  >&lt;p&gt;If the issue is the amount of work, I think I might be able to get time to do this at work. I would just want more discussion around it before I invested time.&lt;/p&gt;</comment>
                            <comment id="181179" author="craiggwilson" created="Wed, 31 Oct 2012 21:35:20 +0000"  >&lt;p&gt;Good suggestion and thanks for creating a Jira for this.  We have discussed this internally but haven&apos;t pulled the trigger yet.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="40425">CSHARP-487</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="150811">CSHARP-1024</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <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|hs0tb3:</customfieldvalue>

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