@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.relational.core.sql.render;
|
||||
|
||||
import org.springframework.data.relational.core.sql.Condition;
|
||||
import org.springframework.data.relational.core.sql.NestedCondition;
|
||||
import org.springframework.data.relational.core.sql.Not;
|
||||
import org.springframework.data.relational.core.sql.Visitable;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -27,7 +26,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Jens Schauder
|
||||
* @since 3.1.6
|
||||
*/
|
||||
class NotConditionVisitor extends TypedSubtreeVisitor<NestedCondition> {
|
||||
class NotConditionVisitor extends TypedSubtreeVisitor<Not> {
|
||||
|
||||
private final RenderContext context;
|
||||
private final RenderTarget target;
|
||||
@@ -63,7 +62,7 @@ class NotConditionVisitor extends TypedSubtreeVisitor<NestedCondition> {
|
||||
|
||||
if (conditionVisitor != null) {
|
||||
|
||||
target.onRendered("NOT (" + conditionVisitor.getRenderedPart() + ")");
|
||||
target.onRendered("NOT " + conditionVisitor.getRenderedPart());
|
||||
conditionVisitor = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -678,6 +678,26 @@ class SelectRendererUnitTests {
|
||||
assertThat(sql).isEqualTo("SELECT atable.* FROM atable WHERE NOT (atable.id = 1 AND atable.id = 2)");
|
||||
}
|
||||
|
||||
@Test // GH-1945
|
||||
void notOfTrue() {
|
||||
|
||||
Select selectFalse = Select.builder().select(Expressions.just("*")).from("test_table")
|
||||
.where(Conditions.just("true").not()).build();
|
||||
String renderSelectFalse = SqlRenderer.create().render(selectFalse);
|
||||
|
||||
assertThat(renderSelectFalse).isEqualTo("SELECT * FROM test_table WHERE NOT true");
|
||||
}
|
||||
|
||||
@Test // GH-1945
|
||||
void notOfNestedTrue() {
|
||||
|
||||
Select selectFalseNested = Select.builder().select(Expressions.just("*")).from("test_table")
|
||||
.where(Conditions.nest(Conditions.just("true")).not()).build();
|
||||
String renderSelectFalseNested = SqlRenderer.create().render(selectFalseNested);
|
||||
|
||||
assertThat(renderSelectFalseNested).isEqualTo("SELECT * FROM test_table WHERE NOT (true)");
|
||||
}
|
||||
|
||||
@Test // GH-1651
|
||||
void asteriskOfAliasedTableUsesAlias() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user