RavenDB 4: Query results with nullable date will return null values when comapring 'greater'

42 views
Skip to first unread message

Severin Meyer

unread,
May 16, 2018, 12:27:38 PM5/16/18
to RavenDB - 2nd generation document database
I would expect to get only results with a real value when querying for DateTime > DateTime.Now
But also null-values are included on 'greater'-compare (not on 'lesser'-compare)

[TestClass]
public class RavenDBTestDriver : RavenTestDriver<MyRavenDBLocator>
{
   
protected override void PreInitialize(IDocumentStore documentStore)
   
{
        documentStore
.OnBeforeQuery += (sender, beforeQueryExecutedArgs) => beforeQueryExecutedArgs.QueryCustomization.WaitForNonStaleResults();
   
}
 
   
[TestMethod]
   
public void QueryDateCompareTest()
   
{
       
using (var store = GetDocumentStore())
       
{
           
using (var session = store.OpenSession())
           
{
                session
.Store(new TestDoc { Id = "Test 1", Birthday = null });
                session
.Store(new TestDoc { Id = "Test 2", Birthday = new DateTime(2000, 1, 1) });
                session
.Store(new TestDoc { Id = "Test 3", Birthday = new DateTime(2010, 1, 1) });
                session
.Store(new TestDoc { Id = "Test 4", Birthday = new DateTime(2015, 1, 1) });
                session
.SaveChanges();
           
}
 
           
using (var session = store.OpenSession())
           
{
               
var query1 = session.Query<TestDoc>().Where(x => x.Birthday == null);
               
var uery1Result = query1.ToList();
               
Assert.AreEqual(1, uery1Result.Count);
 
               
var query2 = session.Query<TestDoc>().Where(x => x.Birthday < new DateTime(2005, 1, 1));
               
var uery2Result = query2.ToList();
               
Assert.AreEqual(1, uery2Result.Count);
 
               
var query3 = session.Query<TestDoc>().Where(x => x.Birthday > new DateTime(2005, 1, 1) );
               
var uery3Result = query3.ToList();
               
Assert.AreEqual(2, uery3Result.Count);
               
// This fails, Test 1 null values included.
           
}
       
}
   
}
 
   
public class TestDoc
   
{
       
public string Id { get; set; }
 
       
public DateTime? Birthday { get; set; }
   
}
}



Oren Eini (Ayende Rahien)

unread,
May 20, 2018, 7:20:14 AM5/20/18
to ravendb
Hi,
Thanks, this will be fixed in the next nightly


Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Oren Eini (Ayende Rahien)

unread,
May 20, 2018, 7:20:26 AM5/20/18
to ravendb

Severin Meyer

unread,
May 21, 2018, 11:18:55 AM5/21/18
to RavenDB - 2nd generation document database
Works, Thank you.
Reply all
Reply to author
Forward
0 new messages