Skip to content

Commit

Permalink
#78: fixed the bug with booleanExpression quotation (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaSergienko authored Jun 19, 2020
1 parent b4e9644 commit bf276be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.exasol</groupId>
<artifactId>sql-statement-builder</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<name>Exasol SQL Statement Builder</name>
<description>This module provides a Builder for SQL statements that helps creating the correct structure and validates variable parts of the statements.</description>
<url>https://github.com/exasol/sql-statement-builder</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

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;
import org.junit.jupiter.api.Test;

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 {
Expand Down Expand Up @@ -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\""));
}
}

0 comments on commit bf276be

Please sign in to comment.