-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Issue type:
[ ] question
[ ] bug report
[x] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ] latest
[ ] @next
[x] 0.2.16 (or put your version here)
Steps to reproduce or a small repository showing the problem:
.createQueryBuilder(User, 'user')
.setLock('pessimistic_write')
.leftJoinAndSelect('user.someAnotherTable', 'someAnotherTable')
.where('email LIKE :email', { email: 'email@mail.com' })
.getOne();Code above generates query:
SELECT "user"."id" AS "user_id",
"someAnotherTable"."id" AS "someAnotherTable_id"
FROM "public"."users" "user"
LEFT JOIN "public"."some_another_table" "someAnotherTable" ON "someAnotherTable"."id"="user"."some_another_table_id"
WHERE email LIKE 'email@mail.com'
FOR UPDATEWhich produce postgresql error:
ERROR: FOR UPDATE cannot be applied to the nullable side of an outer join
Looks like DBMS trying to lock someAnotherTable as well, but typescript code above does not imply that every joined table should be locked (isn't it?).
If so, generated sql code should include part FOR UPDATE OF <> instead of FOR UPDATE:
SELECT "user"."id" AS "user_id",
"someAnotherTable"."id" AS "someAnotherTable_id"
FROM "public"."users" "user"
LEFT JOIN "public"."some_another_table" "someAnotherTable" ON "someAnotherTable"."id"="user"."some_another_table_id"
WHERE email LIKE 'email@mail.com'
FOR UPDATE OF "user"similar issue:
https://code.djangoproject.com/ticket/28010