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

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

Closed
sgnanask opened this issue Oct 30, 2023 · 0 comments
Assignees
Labels
type: bug A general bug

Comments

@sgnanask
Copy link

sgnanask commented Oct 30, 2023

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);
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 30, 2023
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 6, 2023
schauder added a commit that referenced this issue Nov 8, 2023
schauder added a commit that referenced this issue Nov 8, 2023
schauder added a commit that referenced this issue Nov 8, 2023
mp911de pushed a commit that referenced this issue Nov 14, 2023
Closes #1653
Original pull request: #1659
mp911de added a commit that referenced this issue Nov 14, 2023
Introduce prefix operator to express queries as Conditions.not(…) as alternative to myCondition.not() (suffix operator) for easier readability.

Reformat code, update copyright years.

See #1653
Original pull request: #1659
mp911de added a commit that referenced this issue Nov 14, 2023
Introduce prefix operator to express queries as Conditions.not(…) as alternative to myCondition.not() (suffix operator) for easier readability.

Reformat code, update copyright years.

See #1653
Original pull request: #1659
@mp911de mp911de added this to the 3.1.6 (2023.0.6) milestone Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants