<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:06:53 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>[SERVER-4753] array indexes and object subfields should be referenced with different syntax</title>
                <link>https://jira.mongodb.org/browse/SERVER-4753</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;It is currently the case that if you send an update like:&lt;/p&gt;

&lt;p&gt;{ $set: &lt;/p&gt;
{ &quot;foo.0&quot;: &quot;x&quot; }
&lt;p&gt; }&lt;/p&gt;

&lt;p&gt;You may be updating either index 0 of the array foo or the key &quot;0&quot; in an object. If &quot;foo&quot; exists as an array, then it updates index 0. If it&apos;s an object, it updates the key &quot;0&quot;. The problem is that if &quot;foo&quot; doesn&apos;t yet exist, then mongo assumes you want an object.&lt;/p&gt;

&lt;p&gt;This has bitten us a couple times, where we&apos;ve ended up with objects with numeric keys, instead of arrays.&lt;/p&gt;

&lt;p&gt;Ideally the syntax for these two cases would be different so there wouldn&apos;t be ambiguity. For example, array indexes could be referenced with []. It would be difficult to ever deprecate the old dot notation, but callers could switch to the square brackets and not run the risk of having this problem.&lt;/p&gt;</description>
                <environment></environment>
        <key id="29024">SERVER-4753</key>
            <summary>array indexes and object subfields should be referenced with different syntax</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="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="backlog-query-optimization">Backlog - Query Optimization</assignee>
                                    <reporter username="nsanch">Neil Sanchala</reporter>
                        <labels>
                    </labels>
                <created>Tue, 24 Jan 2012 16:35:03 +0000</created>
                <updated>Tue, 6 Dec 2022 05:37:33 +0000</updated>
                                                                            <component>Write Ops</component>
                                        <votes>4</votes>
                                    <watches>13</watches>
                                                                                                                <comments>
                            <comment id="3926195" author="JIRAUSER1261029" created="Fri, 9 Jul 2021 19:57:02 +0000"  >&lt;p&gt;Hi, is there any solution for this ticket? Working example would be good. Thank you.&lt;/p&gt;</comment>
                            <comment id="106656" author="nsanch" created="Wed, 4 Apr 2012 19:24:09 +0000"  >&lt;p&gt;$idx is fine by me.&lt;/p&gt;</comment>
                            <comment id="106644" author="glenn" created="Wed, 4 Apr 2012 19:10:44 +0000"  >&lt;p&gt;It&apos;s a bit ugly, but &lt;/p&gt;
{&quot;foo.$[0]&quot;: &quot;X&quot;}
&lt;p&gt; is unambiguous, since an object key can&apos;t begin with $.&lt;/p&gt;

&lt;p&gt;&quot;foo.$idx&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&quot; might be a bit more future-proof.&lt;/p&gt;

&lt;p&gt;I strongly recommend against &quot;foo&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&quot;.  I have to parse and navigate dotted paths by hand now and then, and that&apos;s a lot more work to parse compared to &apos;a.b.c&apos;.split(&apos;.&apos;).  It&apos;s also still ambiguous.  (Please don&apos;t make brackets special in field names!  There are already too many keys which are valid JSON object keys that aren&apos;t allowed as keys in Mongo, like email addresses.)&lt;/p&gt;</comment>
                            <comment id="82365" author="nsanch" created="Wed, 25 Jan 2012 21:07:09 +0000"  >&lt;p&gt;Got it, thanks for the explanation.&lt;/p&gt;</comment>
                            <comment id="82363" author="scotthernandez" created="Wed, 25 Jan 2012 21:02:46 +0000"  >&lt;p&gt;I think Eliot was just suggesting it as it would break less things since we already have the dot - ordinal notation for arrays, and somewhat special handling for that whole field name (in dot notation) for the &quot;.#.&quot;&lt;/p&gt;</comment>
                            <comment id="82362" author="nsanch" created="Wed, 25 Jan 2012 20:53:36 +0000"  >&lt;p&gt;But if you only use dots for objects and square brackets for arrays there&apos;s no potential ambiguity, and no concerns about existing data with &quot;&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&quot; as a key name in an embedded object. Is there an advantage to using dot-then-square-brackets in the array case given that it introduces ambiguity?&lt;/p&gt;</comment>
                            <comment id="82334" author="scotthernandez" created="Wed, 25 Jan 2012 19:13:32 +0000"  >&lt;p&gt;It is not currently a valid way, no. But the idea is that it could be a syntax to allow more explicit behavior when inserting/update+upsert to affirm you want an array and not a field name.&lt;/p&gt;

&lt;p&gt;As you said, unless there are characters which cannot be used in field names then this could be ambiguous and confusing to some (even if some is &amp;lt; .001 %). It is also possible to declare brackets numbers as special in field names... so that at least it is documented.&lt;/p&gt;</comment>
                            <comment id="82332" author="nsanch" created="Wed, 25 Jan 2012 19:07:51 +0000"  >&lt;p&gt;is foo.&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt; a valid way to reference the key &quot;&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&quot; in the object foo? if so, i&apos;m not a big fan since there&apos;s still some ambiguity there &amp;#8211; mongo would have to decide whether an update to foo.&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt; is supposed to change an object subfield or an array index, and if the foo key doesn&apos;t exist, has to decide whether to make an object or an array. making that decision based on the format of the key is unintuitive at the least, and will bite someone else in the long run.&lt;/p&gt;</comment>
                            <comment id="82201" author="eliot" created="Wed, 25 Jan 2012 06:30:59 +0000"  >&lt;p&gt;this could work:&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;{ $set : { &quot;foo[0]&quot; : &quot;X&quot; } }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;this might be less breaking:&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;{ $set : { &quot;foo.[0]&quot; : &quot;X&quot; } }&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>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="373591">SERVER-28779</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="129302">SERVER-13478</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25126"><![CDATA[Query Optimization]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 25 Jan 2012 06:30:59 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        2 years, 30 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-1253</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>alexander.golin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            2 years, 30 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>astepano@redhat.com</customfieldvalue>
            <customfieldvalue>backlog-query-optimization</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>glenn</customfieldvalue>
            <customfieldvalue>nsanch</customfieldvalue>
            <customfieldvalue>scotthernandez</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrofz3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr2673:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4810</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hsplcv:</customfieldvalue>

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