Skip to content

Commit dd40ba9

Browse files
committed
sync with java: 4c961f143020b34aec8edd04963b599b3475c365
1 parent 3164f2a commit dd40ba9

File tree

5 files changed

+403
-311
lines changed

5 files changed

+403
-311
lines changed

src/Documents/Session/AbstractDocumentQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,12 @@ export abstract class AbstractDocumentQuery<T extends object, TSelf extends Abst
569569
}
570570

571571
public getIndexQuery(): IndexQuery {
572-
let serverVersion = null;
572+
let serverVersion: string = null;
573573
if (this._theSession && this._theSession.requestExecutor) {
574574
serverVersion = this._theSession.requestExecutor.lastServerVersion;
575575
}
576576

577-
const compatibilityMode = serverVersion && serverVersion.compare("4.2") < 0;
577+
const compatibilityMode = serverVersion && serverVersion.localeCompare("4.2") < 0;
578578
const query = this.toString(compatibilityMode);
579579
const indexQuery = this._generateIndexQuery(query);
580580
this.emit("beforeQueryExecuted", indexQuery);

src/Documents/Session/InMemoryDocumentSessionOperations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ export abstract class InMemoryDocumentSessionOperations
16451645
const beforeDeleteEventArgs =
16461646
new SessionBeforeDeleteEventArgs(this, documentInfo.id, documentInfo.entity);
16471647
this.emit("beforeDelete", beforeDeleteEventArgs);
1648-
result.sessionCommands.push(new DeleteCommandData(documentInfo.id, changeVector));
1648+
result.sessionCommands.push(new DeleteCommandData(documentInfo.id, changeVector, documentInfo.changeVector));
16491649
}
16501650

16511651
if (!changes) {

src/Http/RequestExecutor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ export class RequestExecutor implements IDisposable {
11331133
}
11341134

11351135
private static _tryGetServerVersion(response: HttpResponse) {
1136-
return response.headers[HEADERS.SERVER_VERSION];
1136+
return response.headers.get(HEADERS.SERVER_VERSION);
11371137
}
11381138

11391139
private _throwFailedToContactAllNodes<TResult>(
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
import { DocumentStore, SessionOptions } from "../../../src";
3+
import { disposeTestDocumentStore, testContext } from "../../Utils/TestUtil";
4+
import { User } from "../../Assets/Entities";
5+
import { assertThat, assertThrows } from "../../Utils/AssertExtensions";
6+
7+
describe("RavenDB_16614Test", function () {
8+
9+
let store: DocumentStore;
10+
11+
beforeEach(async function () {
12+
store = await testContext.getDocumentStore();
13+
});
14+
15+
afterEach(async () =>
16+
await disposeTestDocumentStore(store));
17+
18+
it("modificationInAnotherTransactionWillFailWithDelete", async () => {
19+
const sessionOptions: SessionOptions = {
20+
transactionMode: "ClusterWide"
21+
};
22+
23+
{
24+
const session = store.openSession(sessionOptions);
25+
const user1 = new User();
26+
user1.name = "arava";
27+
28+
const user2 = new User();
29+
user2.name = "phoebe";
30+
31+
await session.store(user1, "users/arava");
32+
await session.store(user2, "users/phoebe");
33+
await session.saveChanges();
34+
session.dispose();
35+
}
36+
37+
{
38+
const session = store.openSession(sessionOptions);
39+
40+
const user = await session.load("users/arava", User);
41+
await session.delete(user);
42+
const user2 = await session.load("users/phoebe", User);
43+
user2.name = "Phoebe Eini";
44+
45+
{
46+
const conflictedSession = store.openSession(sessionOptions);
47+
const conflictedArava = await conflictedSession.load("users/arava", User);
48+
conflictedArava.name = "Arava!";
49+
await conflictedSession.saveChanges();
50+
conflictedSession.dispose();
51+
}
52+
53+
await assertThrows(async () => await session.saveChanges(), e => {
54+
assertThat(e.name)
55+
.isEqualTo("ClusterTransactionConcurrencyException");
56+
});
57+
}
58+
});
59+
});

0 commit comments

Comments
 (0)