kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 0fc7265fe63e9ed67a0284493cabdaf9d3fec8813b83c62d4fa052a4e278a9b8 |
|---|---|
| Author | Alexandre Dutra <alexdut@gmail.com> · 2015-06-11 14:47 +02:00 |
| Committer | Alexandre Dutra <alexdut@gmail.com> · 2015-06-11 14:47 +02:00 |
| Parents | db6abd0a7648, c41e6ec1f8c8 |
2 files changed
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Utils.java +4 −1
| @@ -59,11 +59,14 @@ | ||
| 59 | 59 | return sb; |
| 60 | 60 | } |
| 61 | 61 | |
| 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, ...) | |
| 63 | 63 | static boolean isSerializable(Object value) { |
| 64 | 64 | if (value instanceof BindMarker || value instanceof FCall || value instanceof CName) |
| 65 | 65 | return false; |
| 66 | 66 | |
| 67 | + if (value instanceof RawString) | |
| 68 | + return false; | |
| 69 | + | |
| 67 | 70 | // We also don't serialize fixed size number types. The reason is that if we do it, we will |
| 68 | 71 | // force a particular size (4 bytes for ints, ...) and for the query builder, we don't want |
| 69 | 72 | // 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 @@ | ||
| 18 | 18 | import java.math.BigDecimal; |
| 19 | 19 | import java.math.BigInteger; |
| 20 | 20 | import java.net.InetAddress; |
| 21 | +import java.nio.ByteBuffer; | |
| 21 | 22 | import java.util.*; |
| 22 | 23 | |
| 23 | 24 | import com.google.common.collect.ImmutableList; |
| @@ -769,4 +770,11 @@ | ||
| 769 | 770 | statement = update("foo").with(prependAll("l", list)).where(eq("k", 1)); |
| 770 | 771 | assertThat(statement.toString()).isEqualTo(query); |
| 771 | 772 | } |
| 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 | + } | |
| 772 | 780 | } |