<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:46:47 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-37713] Views - Date objects are evaluated at time of CreateView(), not time of Query</title>
                <link>https://jira.mongodb.org/browse/SERVER-37713</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;On any version of mongo that supports db.createView() run the following command to create a new view:&lt;/p&gt;

&lt;p&gt;db.createView(&apos;viewName&apos;, &apos;collectionName&apos;, [{$match: { &quot;SomeDateTimeColumn&quot; : &lt;/p&gt;
{ &quot;$gte&quot; : new Date() }
&lt;p&gt; }}])&lt;/p&gt;

&lt;p&gt;Mongo will immediately translate this pipeline to $match: {&quot;SomeDateTimeColumn&quot;: {$gte: ISODate(&quot;Date_And_Time_At_The_Instant_The_View_Was_Created&quot;)}}&lt;/p&gt;

&lt;p&gt;As a result, it appears to be impossible to write any view such as:&lt;br/&gt;
db.createView(&apos;GetItemsWithFutureDate&apos;, &apos;Collection&apos;, &lt;span class=&quot;error&quot;&gt;&amp;#91;\{$match: {$get: Date_Time_At_Moment_Of_Querying_View}}&amp;#93;&lt;/span&gt;)&lt;/p&gt;


&lt;p&gt;This appears to be because this is the same behavior that exists when one runs db.collection.aggregate(pipeline).&#160; When running an aggregate query, date time objects in the pipeline are evaluated at the time of the query.&#160; Since the moment the aggregate query is evaluated is the same moment (roughly) that the aggregate query is run, this makes sense for aggregation queries.&lt;/p&gt;

&lt;p&gt;However, this does not make sense for views.&#160; Evaluation of the DateTime object at view creation, means it appears to be impossible to create views that are based on the current date and time.&lt;/p&gt;

&lt;p&gt;All attempts to use things such as $dateFromString: &quot;now&quot; do not work.&lt;/p&gt;

&lt;p&gt;Things such as $CurrentDate are too restricted for use.&lt;/p&gt;

&lt;p&gt;The proposed $$NOW suggestion in&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-23656&quot; title=&quot;Current timestamp variable for aggregate expressions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-23656&quot;&gt;&lt;del&gt;SERVER-23656&lt;/del&gt;&lt;/a&gt; would potentially solve this problem.&lt;/p&gt;

&lt;p&gt;An alternative solution, would be for the createView command to store the aggregation query string, but not evaluate it until the moment the view is actually queried.&lt;/p&gt;



&lt;p&gt;This affects all versions of mongo that support views&lt;/p&gt;</description>
                <environment></environment>
        <key id="622928">SERVER-37713</key>
            <summary>Views - Date objects are evaluated at time of CreateView(), not time of Query</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="backlog-server-query">Backlog - Query Team</assignee>
                                    <reporter username="robc">Robert Christ</reporter>
                        <labels>
                    </labels>
                <created>Tue, 23 Oct 2018 14:45:50 +0000</created>
                <updated>Tue, 6 Dec 2022 03:15:12 +0000</updated>
                            <resolved>Fri, 26 Oct 2018 15:49:47 +0000</resolved>
                                    <version>4.1.4</version>
                                                    <component>Aggregation Framework</component>
                                        <votes>1</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="2043429" author="charlie.swanson" created="Fri, 26 Oct 2018 15:49:47 +0000"  >&lt;p&gt;We plan to address this problem via &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-23656&quot; title=&quot;Current timestamp variable for aggregate expressions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-23656&quot;&gt;&lt;del&gt;SERVER-23656&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="279103">SERVER-23656</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <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_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25143"><![CDATA[Query]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 26 Oct 2018 15:49:47 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 15 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_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>
                            5 years, 15 weeks, 5 days ago
                        </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>backlog-server-query</customfieldvalue>
            <customfieldvalue>charlie.swanson@mongodb.com</customfieldvalue>
            <customfieldvalue>robc</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hub0xj:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</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;db.createView(&apos;viewName&apos;, &apos;collectionName&apos;, [{$match: { &quot;SomeDateTimeColumn&quot; : &lt;/p&gt;
{ &quot;$gte&quot; : new Date() }
&lt;p&gt; }}])&lt;/p&gt;

&lt;p&gt;new Date() will be the time of the createView call.&lt;/p&gt;

&lt;p&gt;There appears to be no way to create a view that references the date and time the view is queried.&#160; Ie)&#160;db.createView(&apos;GetItemsWithFutureDate&apos;, &apos;Collection&apos;, &lt;span class=&quot;error&quot;&gt;&amp;#91;\{$match: {$get: Date_Time_At_Moment_Of_Querying_View}}&amp;#93;&lt;/span&gt;)&lt;/p&gt;</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|huan6v:</customfieldvalue>

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