Skip to content

Incorrect query generated when not Condition is applied on Where clause of Select statement #1653

Closed
@sgnanask

Description

@sgnanask

The below code generates the query as 'SELECT department.* FROM department' ; instead of 'SELECT department.* FROM department WHERE NOT (department.department_id = 1 AND department.department_id = 2)'

The where clause is being ignored

    Select select = StatementBuilder.select(department.asterisk()).from(department). where(
        Conditions.nest(department.column("department_id").isEqualTo(Expressions.just("1"))
            .and(department.column("department_id").isEqualTo(Expressions.just("2")))).not()).build();
    String sql = SqlRenderer.toString(select);
    System.out.println(sql);

However if I remove the not() condition, the query renders fine as 'SELECT department.* FROM department WHERE (department.department_id = 1 AND department.department_id = 2)'

    Select select = StatementBuilder.select(department.asterisk()).from(department).where(
        Conditions.nest(department.column("department_id").isEqualTo(Expressions.just("1"))
            .and(department.column("department_id").isEqualTo(Expressions.just("2"))))).build();
    String sql = SqlRenderer.toString(select);
    System.out.println(sql);

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions