Permalink
Browse files

Fixing an issue where dynamic queries NOT using temp indexes would ma…

…ke the wrong etag check and would always return the full value after promotion
  • Loading branch information...
1 parent 40711b9 commit a69a905f7a267f857980ac4eb0b48fff9c52aeee @ayende ayende committed Jun 21, 2011
View
2 Raven.Database/Indexing/IndexStorage.cs
@@ -108,6 +108,8 @@ public string[] Indexes
public bool HasIndex(string index)
{
+ if (index == null)
+ return false;
return indexes.ContainsKey(index);
}
View
6 Raven.Database/Queries/DynamicQueryExtensions.cs
@@ -17,11 +17,9 @@ public static QueryResult ExecuteDynamicQuery(this DocumentDatabase self, string
return dynamicQueryRunner.ExecuteDynamicQuery(entityName, indexQuery);
}
- public static string FindDynamicIndexName(this DocumentDatabase self, string entityName, string query)
+ public static string FindDynamicIndexName(this DocumentDatabase self, string entityName, IndexQuery query)
{
- var map = DynamicQueryMapping.Create(self, query, entityName);
-
- return map.IndexName;
+ return new DynamicQueryOptimizer(self).SelectAppropriateIndex(entityName, query);
}
}
}
View
1 Raven.Database/Queries/DynamicQueryOptimizer.cs
@@ -1,3 +1,4 @@
+using System.Runtime.CompilerServices;
using Raven.Abstractions.Data;
using Raven.Abstractions.Indexing;
using System.Linq;
View
5 Raven.Database/Server/Responders/Index.cs
@@ -166,10 +166,11 @@ private QueryResult PerformQueryAgainstDynamicIndex(IHttpContext context, string
if (index.StartsWith("dynamic/"))
entityName = index.Substring("dynamic/".Length);
- var dynamicIndexName = Database.FindDynamicIndexName(entityName, indexQuery.Query);
+ var dynamicIndexName = Database.FindDynamicIndexName(entityName, indexQuery);
- if (Database.IndexStorage.HasIndex(dynamicIndexName))
+ if (dynamicIndexName != null &&
+ Database.IndexStorage.HasIndex(dynamicIndexName))
{
indexEtag = GetIndexEtag(dynamicIndexName);
if (context.MatchEtag(indexEtag))

0 comments on commit a69a905

Please sign in to comment.