Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL - Repository find lock mode for_no_key_update is not being added to query #7717

Closed
2 of 21 tasks
ykovalenko-gentech opened this issue Jun 7, 2021 · 1 comment · Fixed by #8008
Closed
2 of 21 tasks

Comments

@ykovalenko-gentech
Copy link

ykovalenko-gentech commented Jun 7, 2021

Issue Description

When using lock mode for_no_key_update in find method like this:
repository.find({ lock: { mode: 'for_no_key_update' } })
Output query does not have lock.

The reason is missing 'for_no_key_update' check in FindOptionsUtils.ts

} else if (options.lock.mode === "pessimistic_read" || options.lock.mode === "pessimistic_write" || options.lock.mode === "dirty_read" || options.lock.mode === "pessimistic_partial_write" || options.lock.mode === "pessimistic_write_or_fail") {

Expected Behavior

In case of pg driver, I expect adding FOR NO KEY UPDATE to the end of SELECT ..., same as using lock method for QueryBuilder.

Actual Behavior

Lock is not added because of skipping it on repository level and missing on query builder error.
So resulting query is simple select.


Steps to Reproduce

  1. Set lock mode for_no_key_update in find method of repository
`repository.find({ lock: { mode: 'for_no_key_update' } })`

My Environment

Dependency Version
Operating System
Node.js version v14
Typescript version v4.1
TypeORM version v0.2.32

Additional Context

Relevant Database Driver(s)

  • aurora-data-api
  • aurora-data-api-pg
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time, and I know how to start.
  • Yes, I have the time, but I don't know how to start. I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
das-mensch added a commit to das-mensch/typeorm that referenced this issue Aug 2, 2021
FOR NO KEY UPDATE was introduced in typeorm 0.2.25 but the relevant query
part was never added due to missing check in FindOptionUtils

Closes: typeorm#7717
@herenickname

This comment has been minimized.

pleerock pushed a commit that referenced this issue Nov 8, 2021
FOR NO KEY UPDATE was introduced in typeorm 0.2.25 but the relevant query
part was never added due to missing check in FindOptionUtils

Closes: #7717
HeartPattern pushed a commit to HeartPattern/typeorm that referenced this issue Nov 29, 2021
FOR NO KEY UPDATE was introduced in typeorm 0.2.25 but the relevant query
part was never added due to missing check in FindOptionUtils

Closes: typeorm#7717
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants