We are in the process of upgrading to RavenDB 2.5 and are facing a special situation. One of our unit tests suddenly fails for no apparent reason.
Here is some simple code to reproduce the problem:
class Foo { public Guid Id { get; private set; } public DateTime? ExpirationTime { get; set; } public Foo() { Id = Guid.NewGuid(); ExpirationTime = null; } } var documentStore = new EmbeddableDocumentStore { RunInMemory = true, Conventions = { DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites } }; documentStore.Initialize(); using (var session = documentStore.OpenSession()) { session.Store(new Foo()); session.Store(new Foo()); session.SaveChanges(); }
So now we have two documents in the database, as with ExpirationTime = null. This happens when querying the database for these documents:
using (var session = documentStore.OpenSession()) { var bar = session.Query<Foo>().Where(foo => foo.ExpirationTime == null).ToList(); Console.WriteLine("1. Number of documents: {0}", bar.Count); bar = session.Query<Foo>().Where(foo => foo.ExpirationTime == null || foo.ExpirationTime > DateTime.Now).ToList(); Console.WriteLine("2. Number of documents: {0}", bar.Count); bar = session.Query<Foo>().Where(foo => foo.ExpirationTime == null | foo.ExpirationTime > DateTime.Now).ToList(); Console.WriteLine("3. Number of documents: {0}", bar.Count); }
The result of these queries is as follows:
1. Number of documents: 2 2. Number of documents: 0 3. Number of documents: 2
This does not seem right to me ... I would expect that number 2. give 2.
I ran the same queries with the RavenDB server and got the expected results, so it seems like this is a problem with EmbeddableDocumentStore.
During testing, I also found strange behavior when using a boolean or operator in other cases. Sometimes using foo.HasValue will give a different result than foo != null , but this may be due to the same problem.
Has anyone else experienced this issue? Known bug?
source share