Skip to content

Commit 3a6ad3e

Browse files
authored
Merge pull request #358 from ml054/RDBC-682
RDBC-682 Incorrect ModifiedDocument returned in afterSaveChanges sess…
2 parents 1bccd70 + c6f6362 commit 3a6ad3e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/Documents/Commands/Batches/SingleNodeBatchCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export class SingleNodeBatchCommand extends RavenCommand<BatchCommandResult> imp
144144
.objectKeysTransform({
145145
defaultTransform: "camel",
146146
ignoreKeys: [/^@/],
147+
ignorePaths: [/results\.\[\]\.modifiedDocument\./i],
147148
})
148149
.process(bodyStream);
149150
return body;

test/Documents/CustomKeyCaseConventionsTests.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { testContext, disposeTestDocumentStore } from "../Utils/TestUtil";
22
import * as assert from "assert";
33
import DocumentStore, {
4-
IDocumentStore,
4+
IDocumentStore, PatchCommandData, PatchRequest,
55
} from "../../src";
66
import { assertThat } from "../Utils/AssertExtensions";
77

@@ -391,4 +391,33 @@ describe("With custom key case conventions set", function () {
391391
assert.strictEqual(loaded.Equipment[0].Name, stored.equipment[0].name);
392392
}
393393
});
394+
395+
it("returns correct modified document after patch", async () => {
396+
class PascalDoc {
397+
public SIPCall: string
398+
}
399+
400+
{
401+
const session = regularStore.openSession();
402+
const pascalDoc = new PascalDoc();
403+
pascalDoc.SIPCall = "RavenDB";
404+
405+
await session.store(pascalDoc, "pascal/1");
406+
await session.saveChanges();
407+
}
408+
let modifiedDocument
409+
regularStore.addSessionListener("afterSaveChanges", event => {
410+
modifiedDocument = event.entity
411+
});
412+
413+
const session = regularStore.openSession();
414+
await session.load("pascal/1");
415+
416+
const patchRequest = PatchRequest.forScript("this.SIPCall = \"Patched\"");
417+
session.advanced.defer(new PatchCommandData("pascal/1", null, patchRequest))
418+
await session.saveChanges();
419+
420+
assert.strictEqual(modifiedDocument.SIPCall, "Patched")
421+
assert.ok(!("sipCall" in modifiedDocument));
422+
});
394423
});

0 commit comments

Comments
 (0)