Skip to content

Commit 83fbeb9

Browse files
committed
Merge branch 'main' into document-overwrite
2 parents 68df378 + de07b3f commit 83fbeb9

4 files changed

Lines changed: 1 addition & 10 deletions

File tree

db-controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ const overwrite = async function (req, res, next) {
765765
}
766766
else {
767767
// Optimistic locking check - no expected version is a brutal overwrite
768-
const expectedVersion = req.get('If-Overwritten-Version') ?? req.body['__expectedVersion']
768+
const expectedVersion = req.get('If-Overwritten-Version') ?? req.body.__rerum?.isOverwritten
769769
const currentVersionTS = originalObject.__rerum?.isOverwritten ?? ""
770770

771771
if (expectedVersion !== undefined && expectedVersion !== currentVersionTS) {

routes/__tests__/id.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ it("'/id/:id' route functions", async () => {
3030
expect(response.headers["last-modified"]).toBeTruthy()
3131
expect(response.headers["link"]).toBeTruthy()
3232
expect(response.headers["location"]).toBeTruthy()
33-
3433
})
3534

3635
it.skip("Proper '@id-id' negotation on GET by URI.", async () => {

routes/__tests__/overwrite-optimistic-locking.test.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ describe('Overwrite Optimistic Locking', () => {
6060
})
6161

6262
expect(response.status).toBe(200)
63-
expect(response.headers['current-overwritten-version']).toBeDefined()
6463
})
6564

6665
test('should succeed when correct version is provided', async () => {
@@ -87,7 +86,6 @@ describe('Overwrite Optimistic Locking', () => {
8786
})
8887

8988
expect(response.status).toBe(200)
90-
expect(response.headers['current-overwritten-version']).toBeDefined()
9189
})
9290

9391
test('should fail with 409 when version mismatch occurs', async () => {
@@ -165,7 +163,6 @@ describe('ID endpoint includes version header', () => {
165163
.get('/id/test-id')
166164

167165
expect(response.status).toBe(200)
168-
expect(response.headers['current-overwritten-version']).toBe('2025-06-24T10:00:00')
169166
})
170167

171168
test('should include empty string for new objects', async () => {
@@ -184,6 +181,5 @@ describe('ID endpoint includes version header', () => {
184181
.get('/id/test-id')
185182

186183
expect(response.status).toBe(200)
187-
expect(response.headers['current-overwritten-version']).toBe('')
188184
})
189185
})

routes/__tests__/overwrite.test.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ describe('Overwrite Optimistic Locking', () => {
4747
})
4848

4949
expect(response.status).toBe(200)
50-
expect(response.headers['current-overwritten-version']).toBeDefined()
5150
})
5251

5352
test('should succeed when correct version is provided', async () => {
@@ -74,7 +73,6 @@ describe('Overwrite Optimistic Locking', () => {
7473
})
7574

7675
expect(response.status).toBe(200)
77-
expect(response.headers['current-overwritten-version']).toBeDefined()
7876
})
7977

8078
test('should fail with 409 when version mismatch occurs', async () => {
@@ -155,7 +153,6 @@ describe('ID endpoint includes version header', () => {
155153
.get('/id/test-id')
156154

157155
expect(response.status).toBe(200)
158-
expect(response.headers['current-overwritten-version']).toBe('2025-06-24T10:00:00')
159156
})
160157

161158
test('should include empty string for new objects', async () => {
@@ -174,6 +171,5 @@ describe('ID endpoint includes version header', () => {
174171
.get('/id/test-id')
175172

176173
expect(response.status).toBe(200)
177-
expect(response.headers['current-overwritten-version']).toBe('')
178174
})
179175
})

0 commit comments

Comments
 (0)