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

Condition.not is broken #1945

Closed
nkey0 opened this issue Nov 20, 2024 · 2 comments
Closed

Condition.not is broken #1945

nkey0 opened this issue Nov 20, 2024 · 2 comments
Assignees
Labels
type: bug A general bug

Comments

@nkey0
Copy link

nkey0 commented Nov 20, 2024

Version 3.2.2.

class NotConditionVisitor extends TypedSubtreeVisitor<NestedCondition> {

should be

class NotConditionVisitor extends TypedSubtreeVisitor<Not> {

https://github.com/spring-projects/spring-data-relational/blob/main/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/NotConditionVisitor.java#L30

Test to reproduce:

    @Test
    public void broken() {
        // when
        Select selectFalse = Select.builder()
                .select(Expressions.just("*"))
                .from("test_table")
                .where(Conditions.just("true").not())
                .build();
        String renderSelectFalse = SqlRenderer.create().render(selectFalse);
        // then - SELECT * FROM test_table
        assertEquals("SELECT * FROM test_table WHERE NOT true", renderSelectFalse)
    }

To be honest, it feels super dangerous.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 20, 2024
@schauder schauder added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 20, 2024
@schauder schauder self-assigned this Nov 20, 2024
@schauder
Copy link
Contributor

Thanks for finding and reporting this.

You have a double not in your second test.
Could you confirm that that is a mistake? Otherwise I don't understand the test.

where(Conditions.not(Conditions.nest(Conditions.just("true"))).not())
                 ^                                             ^

@nkey0
Copy link
Author

nkey0 commented Nov 20, 2024

Oh, yes, second part of test is broken. but first one seems to be correct.

(updated issue by removing second test)

schauder added a commit that referenced this issue Nov 21, 2024
schauder added a commit that referenced this issue Nov 21, 2024
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

No branches or pull requests

3 participants