Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Will not force to load the document if we aren't required to by the user

  • Loading branch information...
commit 53199e6b844fa84ca3829b37391077e75db7c11a 1 parent 188c970
@ayende ayende authored
View
2  Raven.Database/Impl/DocumentRetriever.cs
@@ -142,7 +142,7 @@ private JsonDocument ExecuteReadTriggersOnRead(JsonDocument resultingDocument, T
// We have to load the document if user explicitly asked for the id, since
// we normalize the casing for the document id on the index, and we need to return
// the id to the user with the same casing they gave us.
- var fetchingId = fieldsToFetch.Fields.Any(fieldToFetch => fieldToFetch == Constants.DocumentIdFieldName);
+ var fetchingId = fieldsToFetch.HasField(Constants.DocumentIdFieldName);
var fieldsToFetchFromDocument = fieldsToFetch.Fields
.Where(fieldToFetch => queryResult.Projection[fieldToFetch] == null)
.ToArray();
View
5 Raven.Database/Indexing/FieldsToFetch.cs
@@ -83,5 +83,10 @@ public void EnsureHasField(string ensuredFieldName)
ensuredFieldNames = new HashSet<string>();
ensuredFieldNames.Add(ensuredFieldName);
}
+
+ public bool HasField(string name)
+ {
+ return fieldsToFetch.Contains(name);
+ }
}
}
View
31 Raven.Tests/MailingList/ProjectionShouldNotLoadDocument.cs
@@ -0,0 +1,31 @@
+// -----------------------------------------------------------------------
+// <copyright file="ProjectionShouldNotLoadDocument.cs" company="Hibernating Rhinos LTD">
+// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
+// </copyright>
+// -----------------------------------------------------------------------
+using Raven.Abstractions.Data;
+using Raven.Json.Linq;
+using Xunit;
+
+namespace Raven.Tests.MailingList
+{
+ public class ProjectionShouldNotLoadDocument : RavenTest
+ {
+ [Fact]
+ public void WhenProjecting()
+ {
+ using (var store = NewDocumentStore())
+ {
+ store.DocumentDatabase.Put("FOO", null, new RavenJObject { { "Name", "Ayende" } }, new RavenJObject(), null);
+ WaitForIndexing(store);
+ var result = store.DatabaseCommands.Query("dynamic", new IndexQuery
+ {
+ FieldsToFetch = new[] { "Name" }
+ }, new string[0]);
+
+ // if this is lower case, then we loaded this from the index, not from the db
+ Assert.Equal("foo", result.Results[0].Value<string>(Constants.DocumentIdFieldName));
+ }
+ }
+ }
+}
View
1  Raven.Tests/Raven.Tests.csproj
@@ -651,6 +651,7 @@
<Compile Include="MailingList\Maxime2.cs" />
<Compile Include="MailingList\Oguzhntopcu.cs" />
<Compile Include="MailingList\Pfeffer.cs" />
+ <Compile Include="MailingList\ProjectionShouldNotLoadDocument.cs" />
<Compile Include="MailingList\QueryIn.cs" />
<Compile Include="MailingList\QueryingOnValueWithMultipleMinusAnalyzed .cs" />
<Compile Include="MailingList\RacielRod.cs" />
View
8 Raven.Tryouts/Program.cs
@@ -15,12 +15,6 @@ class Program
{
static void Main(string[] args)
{
- for (int i = 0; i < 100; i++)
- {
- Console.WriteLine(i);
- using (var x = new PeriodicBackupTests())
- x.CanBackupToDirectory_MultipleBackups();
- }
- }
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.