Pelle
Pelle

Reputation: 2785

Queries with date arguments not returning expected results in RavenDB

I have a working application currently running on RavenDb 2.5. Yesterday I tried moving it to RavenDb 3 (3.0.3599, both server and client) and noticed a lot of unit tests failing. In fact many tests using dates as query parameters was failing. By failing I mean returning zero results where one or more was expected. It looks like queries comparing dates with greater or equals operator >= fails, but less or equals <=works.

Other queries against the same index works as expected.

A typical index looks like this:

   public class GetBidListIndex : AbstractIndexCreationTask<Product, GetBidListIndex.Result>
{
public GetBidListIndex()
{
    this.Map = docs => from p in docs
       from b in p.Bids
       select
           new Result
               {
                   BidId = b.BidId,
                   CustomerNumber = b.CustomerNumber,
                   BasePrice = b.BasePrice,
                   BidValidTo = b.ValidTo,
                   Country = b.Country
               };

    this.StoreAllFields(FieldStorage.Yes);
}

public class Result
{
    public string BidId { get; set; }
    public string CustomerNumber { get; set; }
    public decimal? BasePrice { get; set; }
    public DateTime? BidValidTo { get; set; }
    public string Country { get; set; }
}
}

And a typical query looks like this:

RavenQueryStatistics stats;

 this.Query = this.documentSession.Query<GetBidListIndex.Result, GetBidListIndex>().Statistics(out stats);
 this.Query = from q in this.Query where q.BidValidTo >= bidValidFrom select q;

 var result = this.Query
   .ProjectFromIndexFieldsInto<GetBidListIndex.Result>()
   .Skip(this.PageSize * (this.Page - 1))
   .Take(this.PageSize)
   .ToList();

The database and all test data gets re-generated with each test, so there is no old data lurking.

I can't figure out what is causing this. Is anyone else experiencing this behaviour?

Upvotes: 0

Views: 68

Answers (1)

Ayende Rahien
Ayende Rahien

Reputation: 22956

There is a known issue in 3599 regarding dates queries, we've issued a quick fix in an unstable, and will soon have an update.

Upvotes: 1

Related Questions