Permalink
Browse files

Fixing an issue where querying for properties contained - in them wou…

…ldn't take into account properties which are the same sans the dashes
  • Loading branch information...
1 parent 0fabc51 commit 4c8e41fbc659edb3eb634e39fff15443c78fed63 @ayende ayende committed Aug 3, 2011
Showing with 37 additions and 1 deletion.
  1. +1 −1 Raven.Database/Data/DynamicQueryMapping.cs
  2. +36 −0 Raven.Tests/Bugs/Metadata/Querying.cs
@@ -269,7 +269,7 @@ private void SetupFieldsToIndex(IndexQuery query, IEnumerable<Tuple<string,strin
Items = fields.Select(x => new DynamicQueryMappingItem
{
From = x.Item1,
- To = replaceInvalidCharacterForFields.Replace(x.Item2, ""),
+ To = replaceInvalidCharacterForFields.Replace(x.Item2, "_"),
QueryFrom = x.Item2
}).OrderByDescending(x=>x.QueryFrom.Length).ToArray();
if (GroupByItems != null && DynamicAggregation)
@@ -5,6 +5,7 @@ namespace Raven.Tests.Bugs.Metadata
{
public class Querying : LocalClientTest
{
+ [Fact]
public void Can_query_metadata()
{
using(var DocStore = NewDocumentStore())
@@ -36,5 +37,40 @@ public void Can_query_metadata()
}
}
}
+
+ [Fact]
+ public void Index_should_take_into_account_number_of_dashes()
+ {
+ using (var DocStore = NewDocumentStore())
+ {
+ var user1 = new User { Name = "Joe Schmoe" };
+ using (var session = DocStore.OpenSession())
+ {
+ session.Store(user1);
+ var metadata1 = session.Advanced.GetMetadataFor(user1);
+ metadata1["Test-Property-1"] = "Test-Value-1";
+ session.Store(new User { Name = "Ralph Schmoe" });
+ session.SaveChanges();
+ }
+
+ using (var session = DocStore.OpenSession())
+ {
+ Assert.Empty(session.Advanced.LuceneQuery<User>()
+ .WaitForNonStaleResultsAsOfNow()
+ .WhereEquals("@metadata." + "Test-Property1", "Test-Value-1")
+ .ToList());
+
+ var result = session.Advanced.LuceneQuery<User>()
+ .WaitForNonStaleResultsAsOfNow()
+ .WhereEquals("@metadata." + "Test-Property-1", "Test-Value-1")
+ .ToList();
+
+ Assert.NotNull(result);
+ Assert.Equal(1, result.Count);
+ var metadata = session.Advanced.GetMetadataFor(result[0]);
+ Assert.Equal("Test-Value-1", metadata["Test-Property-1"]);
+ }
+ }
+ }
}
}

0 comments on commit 4c8e41f

Please sign in to comment.