-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing issues with how multi load can now return nulls
- Loading branch information
Showing
2 changed files
with
19 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,22 +27,31 @@ public static class SerializationHelper | |
///</summary> | ||
public static IEnumerable<JsonDocument> RavenJObjectsToJsonDocuments(IEnumerable<RavenJObject> responses) | ||
{ | ||
return (from doc in responses | ||
let metadata = doc["@metadata"] as RavenJObject | ||
let _ = doc.Remove("@metadata") | ||
let key = Extract(metadata, "@id", string.Empty) | ||
let lastModified = Extract(metadata, Constants.LastModified, SystemTime.Now, (string d) => ConvertToUtcDate(d)) | ||
let etag = Extract(metadata, "@etag", Guid.Empty, (string g) => new Guid(g)) | ||
let nai = Extract(metadata, "Non-Authoritative-Information", false, (string b) => Convert.ToBoolean(b)) | ||
select new JsonDocument | ||
var list = new List<JsonDocument>(); | ||
foreach (var doc in responses) | ||
{ | ||
if(doc == null) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ayende
via email
Author
Member
|
||
{ | ||
list.Add(null); | ||
continue; | ||
} | ||
var metadata = (RavenJObject)doc["@metadata"]; | ||
doc.Remove("@metadata"); | ||
var key = Extract(metadata, "@id", string.Empty); | ||
var lastModified = Extract(metadata, Constants.LastModified, SystemTime.Now, (string d) => ConvertToUtcDate(d)); | ||
var etag = Extract(metadata, "@etag", Guid.Empty, (string g) => new Guid(g)); | ||
var nai = Extract(metadata, "Non-Authoritative-Information", false, (string b) => Convert.ToBoolean(b)); | ||
list.Add(new JsonDocument | ||
{ | ||
Key = key, | ||
LastModified = lastModified, | ||
Etag = etag, | ||
NonAuthoritativeInformation = nai, | ||
Metadata = metadata.FilterHeaders(isServerDocument: false), | ||
DataAsJson = doc, | ||
}).ToList(); | ||
}); | ||
} | ||
return list; | ||
} | ||
|
||
///<summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ayende Now that null can be in the return collection, this line:
ravendb/Raven.Client.Lightweight/Document/SessionOperations/MultiLoadOperation.cs
Line 55 in 50f1613
..can throw a NRE. We have this happening in our current codebase.
I can provide a test case that shows this if need be.