Elffuss BraidHub

kikocis/java-driver public

Merge pull request #358 from datastax/java688

JAVA-688 : QueryBuilder doesn't serialize raw strings
Changeset0fc7265fe63e9ed67a0284493cabdaf9d3fec8813b83c62d4fa052a4e278a9b8
AuthorAlexandre Dutra <alexdut@gmail.com> · 2015-06-11 14:47 +02:00
CommitterAlexandre Dutra <alexdut@gmail.com> · 2015-06-11 14:47 +02:00
Parentsdb6abd0a7648, c41e6ec1f8c8

Browse the files at this changeset

2 files changed

modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Utils.java +4 −1
@@ -59,11 +59,14 @@
5959 return sb;
6060 }
6161
62- // Returns null if it's not really serializable (function call, bind markers, ...)
62+ // Returns false if it's not really serializable (function call, bind markers, ...)
6363 static boolean isSerializable(Object value) {
6464 if (value instanceof BindMarker || value instanceof FCall || value instanceof CName)
6565 return false;
6666
67+ if (value instanceof RawString)
68+ return false;
69+
6770 // We also don't serialize fixed size number types. The reason is that if we do it, we will
6871 // force a particular size (4 bytes for ints, ...) and for the query builder, we don't want
6972 // users to have to bother with that.
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderTest.java +8 −0
@@ -18,6 +18,7 @@
1818 import java.math.BigDecimal;
1919 import java.math.BigInteger;
2020 import java.net.InetAddress;
21+import java.nio.ByteBuffer;
2122 import java.util.*;
2223
2324 import com.google.common.collect.ImmutableList;
@@ -769,4 +770,11 @@
769770 statement = update("foo").with(prependAll("l", list)).where(eq("k", 1));
770771 assertThat(statement.toString()).isEqualTo(query);
771772 }
773+
774+ @Test(groups = "unit")
775+ public void should_not_serialize_raw_query_values() {
776+ RegularStatement select = select().from("test").where(gt("i", raw("1")));
777+ assertThat(select.getQueryString()).doesNotContain("?");
778+ assertThat(select.getValues(ProtocolVersion.V3)).isNull();
779+ }
772780 }