Skip to content

Lack of isolation of where conditions #1568

@Godefroy

Description

@Godefroy

Issue type: Bug report
Database system/driver: All SQL databases
TypeORM version: All

WHERE conditions generated by the query builder should all be isolated with parenthesis to avoid bugs due to operators priorities.

Example:

  const entries = await repository.createQueryBuilder()
    .where('field1 = :value OR field2 = :value', { value: 'foo' })
    .andWhere('field3 = :value', { value: 'bar' })
    .getMany();

Result conditions:
WHERE field1 = 'foo' OR field2 = 'foo' AND field3 = 'bar'

Expected conditions:
WHERE (field1 = 'foo' OR field2 = 'foo') AND (field3 = 'bar')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions