带有日期参数的查询未在 RavenDB 中返回预期结果
Queries with date arguments not returning expected results in 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();
每次测试都会重新生成数据库和所有测试数据,因此没有旧数据潜伏。
我不知道是什么原因造成的。还有其他人遇到这种行为吗?
3599 中有一个关于日期查询的已知问题,我们已经发布了一个不稳定的快速修复,很快就会有更新。
我目前 运行 在 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 中有一个关于日期查询的已知问题,我们已经发布了一个不稳定的快速修复,很快就会有更新。