<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:32:36 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-13705] $lte and $gt Query Operators not working properly for String Comparisions</title>
                <link>https://jira.mongodb.org/browse/SERVER-13705</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>
&lt;p&gt;db version v2.4.6&lt;br/&gt;
git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673&lt;/p&gt;</description>
                <environment></environment>
        <key id="133043">SERVER-13705</key>
            <summary>$lte and $gt Query Operators not working properly for String Comparisions</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</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="-1">Unassigned</assignee>
                                    <reporter username="prajjwal1988">Prajjwal</reporter>
                        <labels>
                            <label>query</label>
                    </labels>
                <created>Thu, 24 Apr 2014 10:33:57 +0000</created>
                <updated>Wed, 10 Dec 2014 23:11:14 +0000</updated>
                            <resolved>Thu, 24 Apr 2014 19:22:58 +0000</resolved>
                                    <version>2.4.6</version>
                                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="562043" author="matt.kangas@10gen.com" created="Thu, 24 Apr 2014 19:22:32 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=prajjwal1988&quot; class=&quot;user-hover&quot; rel=&quot;prajjwal1988&quot;&gt;prajjwal1988&lt;/a&gt;, this is working as designed.&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;db.people.find({&quot;name&quot;:{&quot;$lte&quot;:&quot;C&quot; }}) - query for &quot;name&quot; less than the &lt;b&gt;single character&lt;/b&gt; &quot;C&quot;.
	&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
		&lt;li&gt;&quot;Charlie&quot; &amp;lt;= &quot;C&quot; ? no&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;db.people.find({&quot;name&quot;:{&quot;$gt&quot;:&quot;C&quot;}}) - query for &quot;name&quot; greater than the &lt;b&gt;single character&lt;/b&gt; &quot;C&quot;
	&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
		&lt;li&gt;&quot;Charlie&quot; &amp;gt; &quot;C&quot; ? yes&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Perhaps you want to use a &lt;a href=&quot;http://docs.mongodb.org/manual/reference/operator/query/regex/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;$regex&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;The BSON spec does not define sort order for types, but our implementation for String comparison is:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;do memcmp() on UTF8 bytes of the two values&lt;/li&gt;
	&lt;li&gt;when one String is a strict prefix of the other, &lt;b&gt;the longer String is greater&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Here&apos;s the relevant comparison code in v2.6:&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/blame/v2.6/src/mongo/bson/bson-inl.h#L98-L110&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blame/v2.6/src/mongo/bson/bson-inl.h#L98-L110&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also relevant:&lt;br/&gt;
&lt;a href=&quot;http://docs.mongodb.org/manual/reference/bson-types/#string&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://docs.mongodb.org/manual/reference/bson-types/#string&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 24 Apr 2014 19:22:32 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        9 years, 42 weeks, 6 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_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>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            9 years, 42 weeks, 6 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_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>matt.kangas</customfieldvalue>
            <customfieldvalue>prajjwal1988</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrlw87:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>114315</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_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;1. Insert Some Names :&lt;br/&gt;
&amp;gt; db.people.insert(&lt;/p&gt;
{&quot;name&quot;:&quot;Adam&quot;}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.people.insert(&lt;/p&gt;
{&quot;name&quot;:&quot;Bob&quot;}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.people.insert(&lt;/p&gt;
{&quot;name&quot;:&quot;Charlie&quot;}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.people.insert(&lt;/p&gt;
{&quot;name&quot;:&quot;Dwayne&quot;}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.people.insert(&lt;/p&gt;
{&quot;name&quot;:&quot;Elika&quot;}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;2. Query for documents using $lt Query Operator to get all the documents having &quot;name&quot; starting with A,B and C.&lt;br/&gt;
&amp;gt; db.people.find({&quot;name&quot;:{&quot;$lte&quot;:&quot;C&quot;}})&lt;br/&gt;
Actual Output:&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;5358dfdf8211b04a14804731&quot;), &quot;name&quot; : &quot;Adam&quot; }
{ &quot;_id&quot; : ObjectId(&quot;5358dfe38211b04a14804732&quot;), &quot;name&quot; : &quot;Bob&quot; }
&lt;p&gt;Expected Output:&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;5358dfdf8211b04a14804731&quot;), &quot;name&quot; : &quot;Adam&quot; }
{ &quot;_id&quot; : ObjectId(&quot;5358dfe38211b04a14804732&quot;), &quot;name&quot; : &quot;Bob&quot; }
{ &quot;_id&quot; : ObjectId(&quot;5358dfe78211b04a14804733&quot;), &quot;name&quot; : &quot;Charlie&quot; }
&lt;p&gt;It did not return the document where name is &quot;Charlie&quot;.&lt;/p&gt;

&lt;p&gt;Similarly: $gt operator to get all the documents where name starts with Character greater than C, the following query behaves improperly and returns Charlie too. which was not expected.&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Should not return Charlie.&lt;br/&gt;
&amp;gt; db.people.find({&quot;name&quot;:{&quot;$gt&quot;:&quot;C&quot;}})&lt;br/&gt;
Actual Output:
{ &quot;_id&quot; : ObjectId(&quot;5358dfe78211b04a14804733&quot;), &quot;name&quot; : &quot;Charlie&quot; }
{ &quot;_id&quot; : ObjectId(&quot;5358dfef8211b04a14804734&quot;), &quot;name&quot; : &quot;Dwayne&quot; }
{ &quot;_id&quot; : ObjectId(&quot;5358dff78211b04a14804735&quot;), &quot;name&quot; : &quot;Elika&quot; }
&lt;p&gt;Expected Output:&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;5358dfef8211b04a14804734&quot;), &quot;name&quot; : &quot;Dwayne&quot; }
{ &quot;_id&quot; : ObjectId(&quot;5358dff78211b04a14804735&quot;), &quot;name&quot; : &quot;Elika&quot; }&lt;/li&gt;
&lt;/ol&gt;
</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10166" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Tests Written</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10153"><![CDATA[Unneeded]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</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|hsgyh3:</customfieldvalue>

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