Skip to content

Commit

Permalink
Add a couple tests on read database
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorhakes committed Aug 25, 2022
1 parent 5a9ae8f commit 9e7ecf7
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/functional/query-builder/locking/query-builder-locking.ts
Expand Up @@ -1169,6 +1169,49 @@ describe("query builder > locking", () => {
}),
))

it('skip_locked with "pessimistic_read" check getOne', () =>
Promise.all(
connections.map(async (connection) => {
if (
connection.driver.options.type === "postgres" ||
(connection.driver.options.type === "mysql" &&
DriverUtils.isReleaseVersionOrGreater(
connection.driver,
"8.0.0",
))
) {
return connection.manager.transaction((entityManager) => {
return Promise.resolve(
entityManager
.createQueryBuilder(PostWithVersion, "post")
.setLock("pessimistic_read")
.setOnLocked("skip_locked")
.where("post.id = :id", { id: 1 })
.getOne().should.not.be.rejected,
)
})
}
}),
))

it('skip_locked with "for_key_share" check getOne', () =>
Promise.all(
connections.map(async (connection) => {
if (connection.driver.options.type === "postgres") {
return connection.manager.transaction((entityManager) => {
return Promise.resolve(
entityManager
.createQueryBuilder(PostWithVersion, "post")
.setLock("for_key_share")
.setOnLocked("skip_locked")
.where("post.id = :id", { id: 1 })
.getOne().should.not.be.rejected,
)
})
}
}),
))

it('skip_locked with "pessimistic_read" fails on early versions of MySQL', () =>
Promise.all(
connections.map(async (connection) => {
Expand Down

0 comments on commit 9e7ecf7

Please sign in to comment.