具有日期参数的查询未在RavenDB中返回预期结果

时间:2015-02-11 13:16:11

标签: ravendb

我目前正在使用RavenDb 2.5运行应用程序。昨天我尝试将它移动到RavenDb 3(3.0.3599,服务器和客户端),并注意到很多单元测试都失败了。事实上,许多使用日期作为查询参数的测试都失败了。如果失败,我的意思是返回零结果,其中一个或多个是预期的。它看起来像查询 比较日期与更大或等于运算符>=失败,但更少或等于<=有效。

针对同一索引的其他查询按预期工作。

典型的索引如下所示:

   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; }
}
}

典型的查询如下所示:

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();

每次测试都会重新生成数据库和所有测试数据,因此没有潜伏的旧数据。

我无法弄清楚造成这种情况的原因。还有其他人遇到过这种行为吗?

1 个答案:

答案 0 :(得分:1)

3599中有一个关于日期查询的已知问题,我们已经在不稳定版本中发布了快速修复,并且很快就会有更新。

相关问题