kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | a0bc0c0ae9182d51eacb0256e312c6c0dc5d8ec5ea55bc23d86b42bfc6c15eb2 |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2015-03-06 17:55 -08:00 |
| Committer | Olivier Michallat <olim7t@users.noreply.github.com> · 2015-03-06 17:55 -08:00 |
| Parents | c24f41b39166, b3c17058c9fd |
3 files changed
modified driver-core/CHANGELOG.rst +2 −0
| @@ -14,6 +14,8 @@ | ||
| 14 | 14 | - [improvement] Use List<?> instead of List<Object> in QueryBuilder API |
| 15 | 15 | (JAVA-631) |
| 16 | 16 | - [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) | |
| 17 | 19 | |
| 18 | 20 | Merged from 2.0.9_fixes branch: |
| 19 | 21 |
modified driver-core/src/main/java/com/datastax/driver/core/TableMetadata.java +1 −1
| @@ -413,7 +413,7 @@ | ||
| 413 | 413 | and(sb, formatted).append("bloom_filter_fp_chance = ").append(options.bfFpChance); |
| 414 | 414 | and(sb, formatted).append("caching = '").append(options.caching).append('\''); |
| 415 | 415 | 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('\''); | |
| 417 | 417 | and(sb, formatted).append("compaction = ").append(formatOptionMap(options.compaction)); |
| 418 | 418 | and(sb, formatted).append("compression = ").append(formatOptionMap(options.compression)); |
| 419 | 419 | 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 |