Elffuss BraidHub

kikocis/java-driver public

JAVA-688 : QueryBuilder doesn't serialize raw strings
Changesetc41e6ec1f8c817ba161563a533640e32ff454308586717b87102cd7558f1b4c4
AuthorKevin Gallardo <kevin.gallardo@datastax.com> · 2015-05-26 10:18 +02:00
CommitterKevin Gallardo <kevin.gallardo@datastax.com> · 2015-06-08 11:04 +01:00
Parents83fd1d67c7b9

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;
@@ -767,4 +768,11 @@
767768 statement = update("foo").with(prependAll("l", list)).where(eq("k", 1));
768769 assertThat(statement.toString()).isEqualTo(query);
769770 }
771+
772+ @Test(groups = "unit")
773+ public void should_not_serialize_raw_query_values() {
774+ RegularStatement select = select().from("test").where(gt("i", raw("1")));
775+ assertThat(select.getQueryString()).doesNotContain("?");
776+ assertThat(select.getValues(ProtocolVersion.V3)).isNull();
777+ }
770778 }