We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With a certain combination of a where/search query, the query does not seem to be translated correctly:
The following query:
session .Query<TestDocumentIndex.Result, TestDocumentIndex>() .Where(d => d.Category == "A" || d.Category == "B") .Search(d => d.Name, "Peter*")
is translated into
from index 'TestDocumentIndex' where Category = $p0 or Category = $p1 and search(Name, $p2)
It looks like the braces are set incorrectly? Below is a failing test that demonstrates the problem:
Tested versions: 5.4.117 and 6.0.101
using Raven.Client.Documents; using Raven.Client.Documents.Indexes; using Raven.Client.Documents.Linq; using Raven.TestDriver; using Xunit; namespace RavenUnitTests; public class RavenBug : RavenTestDriver { [Fact] public void WhereSearchCombination() { using var store = GetDocumentStore(); store.ExecuteIndex(new TestDocumentIndex()); using (var session = store.OpenSession()) { session.Store(new TestDocument { Category = "A", Name = "Peter Fox" }); session.Store(new TestDocument { Category = "B", Name = "Peter Balzli" }); session.Store(new TestDocument { Category = "A", Name = "John Smith" }); session.SaveChanges(); } WaitForIndexing(store); using (var session = store.OpenSession()) { var documents = session .Query<TestDocumentIndex.Result, TestDocumentIndex>() .Where(d => d.Category == "A" || d.Category == "B") .Search(d => d.Name, "Peter*") .As<TestDocument>() .ToList(); Assert.Equal(2, documents.Count); Assert.Single(documents, d => d.Name == "Peter Fox"); Assert.Single(documents, d => d.Name == "Peter Balzli"); } } private class TestDocumentIndex : AbstractIndexCreationTask<TestDocument, TestDocumentIndex.Result> { public class Result { public string Category { get; init; } public string Name { get; init; } } public TestDocumentIndex() { Map = documents => from document in documents select new { document.Category, document.Name }; Index(x => x.Name, FieldIndexing.Search); } } private class TestDocument { public string Category { get; init; } public string Name { get; init; } } }
The text was updated successfully, but these errors were encountered:
That certainly looks like a bug, yes.
Sorry, something went wrong.
I've created an issue for this, we'll fix the translation. https://issues.hibernatingrhinos.com/issue/RavenDB-22323/Parentheses-missing-when-combining-Where-and-Search-clause
Thanks for noticing this bug!
Thank you @Lwiel!
Fixed in #18516
Lwiel
No branches or pull requests
With a certain combination of a where/search query, the query does not seem to be translated correctly:
The following query:
is translated into
It looks like the braces are set incorrectly? Below is a failing test that demonstrates the problem:
Tested versions: 5.4.117 and 6.0.101
The text was updated successfully, but these errors were encountered: