File tree Expand file tree Collapse file tree
main/java/com/datastax/driver/core
test/java/com/datastax/driver/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ CHANGELOG
1414- [improvement] Use List<?> instead of List<Object> in QueryBuilder API
1515 (JAVA-631)
1616- [improvement] Exclude Netty POM from META-INF in shaded JAR (JAVA-654)
17+ - [bug] Quote single quotes contained in table comments in asCQLQuery method
18+ (JAVA-655)
1719
1820Merged from 2.0.9_fixes branch:
1921
Original file line number Diff line number Diff line change @@ -413,7 +413,7 @@ private String asCQLQuery(boolean formatted) {
413413 and (sb , formatted ).append ("bloom_filter_fp_chance = " ).append (options .bfFpChance );
414414 and (sb , formatted ).append ("caching = '" ).append (options .caching ).append ('\'' );
415415 if (options .comment != null )
416- and (sb , formatted ).append ("comment = '" ).append (options .comment ).append ('\'' );
416+ and (sb , formatted ).append ("comment = '" ).append (options .comment . replace ( "'" , "''" ) ).append ('\'' );
417417 and (sb , formatted ).append ("compaction = " ).append (formatOptionMap (options .compaction ));
418418 and (sb , formatted ).append ("compression = " ).append (formatOptionMap (options .compression ));
419419 if (cassandraVersion .getMajor () >= 2 ) {
Original file line number Diff line number Diff line change 1+ package com .datastax .driver .core ;
2+
3+ import java .util .Collection ;
4+
5+ import com .google .common .collect .Lists ;
6+ import org .testng .annotations .Test ;
7+
8+ import static org .assertj .core .api .Assertions .assertThat ;
9+
10+ public class TableMetadataTest extends CCMBridge .PerClassSingleNodeCluster {
11+ @ Override
12+ protected Collection <String > getTableDefinitions () {
13+ return Lists .newArrayList (
14+ "CREATE TABLE single_quote (\n "
15+ + " c1 int PRIMARY KEY\n "
16+ + ") WITH comment = 'comment with single quote '' should work'"
17+ );
18+ }
19+
20+ @ Test (groups = "short" )
21+ public void should_escape_single_quote_table_comment () {
22+ TableMetadata table = cluster .getMetadata ().getKeyspace ("ks" ).getTable ("single_quote" );
23+ assertThat (table .asCQLQuery ()).contains ("comment with single quote '' should work" );
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments