Linq RavenDB EmbeddedableDocumentStore中可能存在的错误
我们正在升级到RavenDB 2.5,遇到了一个特殊的情况。 我们的一个单元测试突然失败了,而且没有明显的原因 下面是一些简单的代码来重现这个问题:Linq RavenDB EmbeddedableDocumentStore中可能存在的错误,linq,ravendb,Linq,Ravendb,我们正在升级到RavenDB 2.5,遇到了一个特殊的情况。 我们的一个单元测试突然失败了,而且没有明显的原因 下面是一些简单的代码来重现这个问题: class Foo { public Guid Id { get; private set; } public DateTime? ExpirationTime { get; set; } public Foo() { Id = Guid.NewGuid(); ExpirationT
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();
}
因此,现在数据库中有两个文档,它们的ExpirationTime=null。
这是在数据库中查询这些文档时发生的情况:
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);
}
这对我来说似乎不正确。。。我也希望是2号。给2
我在RavenDB服务器上运行了相同的查询,得到了预期的结果,因此这似乎是EmbeddedBledDocumentStore的问题
在测试时,我还发现在其他情况下使用逻辑or运算符时会出现一些奇怪的行为。有时使用foo.HasValue
会得到与foo!=null,但这可能与同一问题有关
还有谁遇到过这个问题?已知错误?这是RavenDB中与空字段排序相关的错误。
在下一个构建中修复了它是否可能是具有过时索引的东西?@NoLifeKing我没有在示例代码中显示它,但在单元测试时,我总是使用DefaultQueryingConsistency=consistency选项。QueryYourWrites
或waitfornonstaleresultsafsoflastwrite()
。此外,在升级到Raven 2.5之前,此功能也按预期工作。请将失败的单元测试发送到邮件服务器list@AyendeRahien我刚刚做到了:-)
1. Number of documents: 2
2. Number of documents: 0
3. Number of documents: 2