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

docs: add Lock tables in Set Locking #10921

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

youngkiu
Copy link
Contributor

@youngkiu youngkiu commented Jun 8, 2024

Description of change

I had a similar issue #4084.

So, I searched the documentation, and although there was a Lock version, there was no explanation for the Lock tables argument, so I added it.

https://orkhan.gitbook.io/typeorm/docs/select-query-builder#set-locking


The issue situation I encountered is as follows.

        transaction
            .getRepository(User)
            .createQueryBuilder('user')
            .setLock('pessimistic_write')
            .leftJoinAndSelect('user.post', 'post')
            .where('user.id = :userId', { userId })
            .getOne();

PlatformTools.ts:239error: error: FOR UPDATE cannot be applied to the nullable side of an outer join

I solved it by looking at the typeorm internal code and modifying it as follows.

        transaction
            .getRepository(User)
            .createQueryBuilder('user')
-            .setLock('pessimistic_write')
+            .setLock('pessimistic_write', undefined, ['user'])
            .leftJoinAndSelect('user.post', 'post')
            .where('user.id = :userId', { userId })
            .getOne();

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant