From bf276bee94f4f10d5c658db91cdc22b0c3611370 Mon Sep 17 00:00:00 2001 From: Anastasiia Sergienko <46891819+AnastasiiaSergienko@users.noreply.github.com> Date: Fri, 19 Jun 2020 16:04:30 +0200 Subject: [PATCH] #78: fixed the bug with booleanExpression quotation (#79) --- pom.xml | 2 +- .../sql/rendering/AbstractFragmentRenderer.java | 2 +- .../dql/select/rendering/TestSelectRendering.java | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4f895345..349973be 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.exasol sql-statement-builder - 3.3.0 + 3.3.1 Exasol SQL Statement Builder This module provides a Builder for SQL statements that helps creating the correct structure and validates variable parts of the statements. https://github.com/exasol/sql-statement-builder diff --git a/src/main/java/com/exasol/sql/rendering/AbstractFragmentRenderer.java b/src/main/java/com/exasol/sql/rendering/AbstractFragmentRenderer.java index 994ac3cf..8242267d 100644 --- a/src/main/java/com/exasol/sql/rendering/AbstractFragmentRenderer.java +++ b/src/main/java/com/exasol/sql/rendering/AbstractFragmentRenderer.java @@ -64,7 +64,7 @@ protected void appendCommaWhenNeeded(final Fragment fragment) { } protected void appendRenderedBooleanExpression(final BooleanExpression expression) { - final BooleanExpressionRenderer expressionRenderer = new BooleanExpressionRenderer(); + final BooleanExpressionRenderer expressionRenderer = new BooleanExpressionRenderer(this.config); expression.accept(expressionRenderer); append(expressionRenderer.render()); } diff --git a/src/test/java/com/exasol/sql/dql/select/rendering/TestSelectRendering.java b/src/test/java/com/exasol/sql/dql/select/rendering/TestSelectRendering.java index ff4a8950..b5b08070 100644 --- a/src/test/java/com/exasol/sql/dql/select/rendering/TestSelectRendering.java +++ b/src/test/java/com/exasol/sql/dql/select/rendering/TestSelectRendering.java @@ -2,6 +2,7 @@ import static com.exasol.hamcrest.SqlFragmentRenderResultMatcher.rendersTo; import static com.exasol.hamcrest.SqlFragmentRenderResultMatcher.rendersWithConfigTo; +import static com.exasol.sql.expression.BooleanTerm.eq; import static org.hamcrest.MatcherAssert.assertThat; import org.junit.jupiter.api.BeforeEach; @@ -9,7 +10,7 @@ import com.exasol.sql.StatementFactory; import com.exasol.sql.dql.select.Select; -import com.exasol.sql.expression.BooleanTerm; +import com.exasol.sql.expression.*; import com.exasol.sql.rendering.StringRendererConfig; class TestSelectRendering { @@ -92,4 +93,13 @@ void testSelectWithQuotedIdentifiersDoesNotAddExtraQuotes() { assertThat(this.select.field("\"fieldA\"", "\"tableA\".fieldB"), rendersWithConfigTo(config, "SELECT \"fieldA\", \"tableA\".\"fieldB\"")); } + + @Test + void testQuotedIdentifiers() { + final StringRendererConfig config = StringRendererConfig.builder().quoteIdentifiers(true).build(); + Select select = this.select.all(); + select.from().table("person"); + select.where(eq(ExpressionTerm.stringLiteral("foo"), ColumnReference.of("test"))); + assertThat(select, rendersWithConfigTo(config, "SELECT * FROM \"person\" WHERE 'foo' = \"test\"")); + } } \ No newline at end of file