kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 6b308c172318f9cc8dd1b5896fd38b16d4ad375d1e5a991127fdcd9268b835fa |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-03-06 17:58 -08:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-03-06 17:58 -08:00 |
| Parents | 686577c52c0a, a0bc0c0ae918 |
3 files changed
modified driver-core/CHANGELOG.rst +2 −0
| @@ -22,6 +22,8 @@ | ||
| 22 | 22 | - [improvement] Use List<?> instead of List<Object> in QueryBuilder API |
| 23 | 23 | (JAVA-631) |
| 24 | 24 | - [improvement] Exclude Netty POM from META-INF in shaded JAR (JAVA-654) |
| 25 | +- [bug] Quote single quotes contained in table comments in asCQLQuery method | |
| 26 | + (JAVA-655) | |
| 25 | 27 | - [bug] Prevent race between cancellation and query completion (JAVA-614) |
| 26 | 28 | - [bug] Prevent cancel and timeout from cancelling unrelated ResponseHandler if |
| 27 | 29 | streamId was already released and reused (JAVA-632). |
modified driver-core/src/main/java/com/datastax/driver/core/TableMetadata.java +1 −1
| @@ -436,7 +436,7 @@ | ||
| 436 | 436 | else |
| 437 | 437 | and(sb, formatted).append("caching = ").append(formatOptionMap(options.caching)); |
| 438 | 438 | if (options.comment != null) |
| 439 | - and(sb, formatted).append("comment = '").append(options.comment).append('\''); | |
| 439 | + and(sb, formatted).append("comment = '").append(options.comment.replace("'","''")).append('\''); | |
| 440 | 440 | and(sb, formatted).append("compaction = ").append(formatOptionMap(options.compaction)); |
| 441 | 441 | and(sb, formatted).append("compression = ").append(formatOptionMap(options.compression)); |
| 442 | 442 | if (cassandraVersion.getMajor() >= 2) { |
added driver-core/src/test/java/com/datastax/driver/core/TableMetadataTest.java +25 −0
| @@ -0,0 +1,25 @@ | ||
| 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 | +} | |
| No newline at the end of the file |