kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | c41e6ec1f8c817ba161563a533640e32ff454308586717b87102cd7558f1b4c4 |
|---|---|
| Author | Kevin Gallardo <kevin.gallardo@datastax.com> · 2015-05-26 10:18 +02:00 |
| Committer | Kevin Gallardo <kevin.gallardo@datastax.com> · 2015-06-08 11:04 +01:00 |
| Parents | 83fd1d67c7b9 |
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; |
| @@ -767,4 +768,11 @@ | ||
| 767 | 768 | statement = update("foo").with(prependAll("l", list)).where(eq("k", 1)); |
| 768 | 769 | assertThat(statement.toString()).isEqualTo(query); |
| 769 | 770 | } |
| 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 | + } | |
| 770 | 778 | } |