Fixes issues with parameters being escaped incorrectly in Python CQL
patch by Tyler Hobbs; reviewed by Pavel Yaskevich for CASSANDRA-2993
git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.8@1156198 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index df035fc..bde2dab 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,7 +4,7 @@
* avoid doing read for no-op replicate-on-write at CL=1 (CASSANDRA-2892)
* refuse counter write for CL.ANY (CASSANDRA-2990)
* switch back to only logging recent dropped messages (CASSANDRA-3004)
-
+ * fix issues with parameters being escaped incorrectly in Python CQL (CASSANDRA-2993)
0.8.3
* add ability to drop local reads/writes that are going to timeout
diff --git a/src/java/org/apache/cassandra/cql/Cql.g b/src/java/org/apache/cassandra/cql/Cql.g
index cde8f3d..b884fc5 100644
--- a/src/java/org/apache/cassandra/cql/Cql.g
+++ b/src/java/org/apache/cassandra/cql/Cql.g
@@ -555,7 +555,7 @@
STRING_LITERAL
: '\''
{ StringBuilder b = new StringBuilder(); }
- ( c=~('\''|'\r'|'\n') { b.appendCodePoint(c);}
+ ( c=~('\'') { b.appendCodePoint(c);}
| '\'' '\'' { b.appendCodePoint('\'');}
)*
'\''
diff --git a/test/system/test_cql.py b/test/system/test_cql.py
index 61b3000..435d752 100644
--- a/test/system/test_cql.py
+++ b/test/system/test_cql.py
@@ -720,7 +720,25 @@
assert len(r) == 1, "wrong number of results"
d = cursor.description
assert d[0][0] == "x'and'y"
-
+
+ def test_newline_strings(self):
+ "reading and writing strings w/ newlines"
+ cursor = init()
+
+ cursor.execute("""
+ UPDATE StandardString1 SET :name = :val WHERE KEY = :key;
+ """, {"key": "\nkey", "name": "\nname", "val": "\nval"})
+
+ cursor.execute("""
+ SELECT :name FROM StandardString1 WHERE KEY = :key
+ """, {"key": "\nkey", "name": "\nname"})
+ assert cursor.rowcount == 1
+ r = cursor.fetchone()
+ assert len(r) == 1, "wrong number of results"
+ d = cursor.description
+ assert d[0][0] == "\nname"
+ assert r[0] == "\nval"
+
def test_typed_keys(self):
"using typed keys"
cursor = init()