Skip to content

Commit

Permalink
* #401: Fixed review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaSergienko committed Nov 11, 2020
1 parent 66454d9 commit 69ef11d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ public NullSorting getDefaultNullSorting() {
@Override
// http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01031.0400/doc/html/asc1252677176370.html
public String getStringLiteral(final String value) {
return SybaseIdentifier.of(value).quote();
if (value.contains("\n") || value.contains("\r")) {
throw new IllegalArgumentException("Sybase string literal contains illegal characters.");
}
return super.quoteLiteralStringWithSingleQuote(value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ void visitSqlFunctionAggregateGroupConcat() throws AdapterException {
final SqlFunctionAggregateGroupConcat aggregateGroupConcat = SqlFunctionAggregateGroupConcat.builder(argument)
.separator(new SqlLiteralString("'")).orderBy(orderBy).distinct(true).build();
assertThat(this.visitor.visit(aggregateGroupConcat), equalTo(
"LISTAGG('value \\''', '\\''') WITHIN GROUP(ORDER BY \"\"\"test_column\" DESC NULLS FIRST, \"test_column2\"\"\")"));
"LISTAGG('value \\'', '\\'') WITHIN GROUP(ORDER BY \"\"\"test_column\" DESC NULLS FIRST, \"test_column2\"\"\")"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ void testGetLiteralString(final String definition) {
equalTo(definition.substring(definition.indexOf(':') + 1)));
}

@ValueSource(strings = { "a\nb", "a\rb", "\r\n" })
@ParameterizedTest
void testGetLiteralStringWithIllegalChars(final String value) {
assertThrows(IllegalArgumentException.class, () -> this.dialect.getStringLiteral(value));
}

@Test
void testRequiresCatalogQualifiedTableNames() {
assertThat(this.dialect.requiresCatalogQualifiedTableNames(null), equalTo(true));
Expand Down

0 comments on commit 69ef11d

Please sign in to comment.