-
-
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
[x] mssql
[x] mysql / mariadb
[x] oracle
[x] postgres
[ ] cockroachdb
[x] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ] latest
[ ] @next
[x] 0.2.25
It would be nice if the expression passed to where() and andWhere() methods of QueryBuilder was surrounded by parentheses.
For example, the following code
qb("User", "user")
.where("user.deleteDate IS NULL") // expression (A)
.andWhere("user.name = 'foo' OR user.birthDate IS NULL"); // expression (B or C) currently generates the following SQL sentence:
SELECT `user`.`id`, `user`.`name`, `user`.`birthDate`, `user`.`deleteDate`
FROM `User` `user`
WHERE `user`.`deleteDate` IS NULL
AND `user`.`name` = 'foo'
OR `user`.`birthDate` IS NULLAs can be seen, the resulting WHERE clause is A and B or C. But it would make more sense if it was (A) and (B or C) - because A was passed to where() and B or C was passed to andWhere().
I know that I can achieve this result by manually including the parentheses to every where condition. But, in my opinion, adding the parentheses automagically in SQL sentence generation would be better.