我有一个正在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();
每次测试都会重新生成数据库和所有测试数据,因此不会隐藏旧数据。
我不知道是什么原因造成的。有其他人经历过这种行为吗?
3599中有一个关于日期查询的已知问题,我们已经在不稳定的中发布了快速修复程序,很快就会有更新。