Elffuss BraidHub

kikocis/java-driver public

JAVA-983: QueryBuilder cannot handle collections containing function calls.

This commit also incidentally formats INSERT statements with a whitestpace between table name and column list,
so that they do not look like a function call.
Changeset1cbac626deafd695e3ce06db6e64fa9cca3fc5c0ee2da65d0704b97c5af4cf3b
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2015-11-10 10:55 +01:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2015-11-16 23:18 +01:00
Parents6dfe1c19ca9a

Browse the files at this changeset

10 files changed

modified changelog/README.md +1 −1
@@ -31,7 +31,7 @@
3131 - [improvement] JAVA-652: Add DCAwareRoundRobinPolicy builder.
3232 - [improvement] JAVA-808: Add generic filtering policy that can be used to exclude specific DCs.
3333 - [bug] JAVA-988: Metadata.handleId should handle escaped double quotes.
34-
34+- [bug] JAVA-983: QueryBuilder cannot handle collections containing function calls.
3535
3636
3737 ### 3.0.0-alpha4
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/BuiltStatement.java +2 −2
@@ -169,11 +169,11 @@
169169
170170 // TODO: Correctly document the InvalidTypeException
171171 void maybeAddRoutingKey(String name, Object value) {
172- if (routingKeyValues == null || name == null || value == null || value instanceof BindMarker)
172+ if (routingKeyValues == null || name == null || value == null || Utils.containsSpecialValue(value))
173173 return;
174174
175175 for (int i = 0; i < partitionKey.size(); i++) {
176- if (name.equals(partitionKey.get(i).getName()) && Utils.isRawValue(value)) {
176+ if (name.equals(partitionKey.get(i).getName())) {
177177 routingKeyValues.set(i, value);
178178 return;
179179 }
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Insert.java +1 −1
@@ -56,7 +56,7 @@
5656 if (keyspace != null)
5757 Utils.appendName(keyspace, builder).append('.');
5858 Utils.appendName(table, builder);
59- builder.append('(');
59+ builder.append(" (");
6060 Utils.joinAndAppendNames(builder, codecRegistry, ",", names);
6161 builder.append(") VALUES (");
6262 Utils.joinAndAppendValues(builder, codecRegistry, ",", values, variables);
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Utils.java +103 −26
@@ -20,12 +20,12 @@
2020 import java.util.Collection;
2121 import java.util.List;
2222 import java.util.Map;
23+import java.util.Set;
2324 import java.util.regex.Pattern;
2425
2526 import static com.google.common.base.Preconditions.checkNotNull;
2627
27-import com.datastax.driver.core.CodecRegistry;
28-import com.datastax.driver.core.TypeCodec;
28+import com.datastax.driver.core.*;
2929
3030 // Static utilities private to the query builder
3131 abstract class Utils {
@@ -59,16 +59,6 @@
5959 return sb;
6060 }
6161
62- private static boolean isForceAppendToQueryString(Object value) {
63- // Force append to query string for all fixed-size number types.
64- // The reason is that if we don't do it, we will
65- // force a particular size (4 bytes for ints, ...)
66- // and for the query builder, we don't want
67- // users to have to bother with that.
68- // TODO this probably does not work well with custom codecs for fixed-size numbers (int, bigint, float, double)
69- return value instanceof Number && !(value instanceof BigInteger || value instanceof BigDecimal);
70- }
71-
7262 static StringBuilder appendValue(Object value, CodecRegistry codecRegistry, StringBuilder sb, List<Object> variables) {
7363 if (value == null) {
7464 sb.append("null");
@@ -87,7 +77,16 @@
8777 appendName(((CName)value).name, codecRegistry, sb);
8878 } else if (value instanceof RawString) {
8979 sb.append(value.toString());
90- } else if (variables == null || isForceAppendToQueryString(value)) {
80+ } else if(value instanceof List && !isSerializable(value)) {
81+ // bind variables are not supported inside collection literals
82+ appendList((List<?>)value, codecRegistry, sb, null);
83+ } else if(value instanceof Set && !isSerializable(value)) {
84+ // bind variables are not supported inside collection literals
85+ appendSet((Set<?>)value, codecRegistry, sb, null);
86+ } else if(value instanceof Map && !isSerializable(value)) {
87+ // bind variables are not supported inside collection literals
88+ appendMap((Map<?,?>)value, codecRegistry, sb, null);
89+ } else if (variables == null || !isSerializable(value)) {
9190 // we are not collecting statement values (variables == null)
9291 // or the value is meant to be forcefully appended to the query string:
9392 // format it with the appropriate codec and append it now
@@ -104,20 +103,105 @@
104103 return sb;
105104 }
106105
106+ private static StringBuilder appendList(List<?> l, CodecRegistry codecRegistry, StringBuilder sb, List<Object> variables) {
107+ sb.append('[');
108+ for (int i = 0; i < l.size(); i++) {
109+ if (i > 0)
110+ sb.append(',');
111+ appendValue(l.get(i), codecRegistry, sb, variables);
112+ }
113+ sb.append(']');
114+ return sb;
115+ }
116+
117+ private static StringBuilder appendSet(Set<?> s, CodecRegistry codecRegistry, StringBuilder sb, List<Object> variables) {
118+ sb.append('{');
119+ boolean first = true;
120+ for (Object elt : s) {
121+ if (first) first = false; else sb.append(',');
122+ appendValue(elt, codecRegistry, sb, variables);
123+ }
124+ sb.append('}');
125+ return sb;
126+ }
127+
128+ private static StringBuilder appendMap(Map<?, ?> m, CodecRegistry codecRegistry, StringBuilder sb, List<Object> variables) {
129+ sb.append('{');
130+ boolean first = true;
131+ for (Map.Entry<?, ?> entry : m.entrySet()) {
132+ if (first)
133+ first = false;
134+ else
135+ sb.append(',');
136+ appendValue(entry.getKey(), codecRegistry, sb, variables);
137+ sb.append(':');
138+ appendValue(entry.getValue(), codecRegistry, sb, variables);
139+ }
140+ sb.append('}');
141+ return sb;
142+ }
143+
107144 static boolean containsBindMarker(Object value) {
108145 if (value instanceof BindMarker)
109146 return true;
110-
111- if (!(value instanceof FCall))
112- return false;
113-
114- FCall fcall = (FCall)value;
115- for (Object param : fcall.parameters)
147+ if (value instanceof FCall)
148+ for (Object param : ((FCall)value).parameters)
116149 if (containsBindMarker(param))
117150 return true;
151+ if (value instanceof Collection)
152+ for (Object elt : (Collection)value)
153+ if (containsBindMarker(elt))
154+ return true;
155+ if (value instanceof Map)
156+ for (Map.Entry<?,?> entry : ((Map<?,?>)value).entrySet())
157+ if (containsBindMarker(entry.getKey()) || containsBindMarker(entry.getValue()))
158+ return true;
159+ return false;
160+ }
161+
162+ static boolean containsSpecialValue(Object value) {
163+ if (value instanceof BindMarker || value instanceof FCall || value instanceof CName || value instanceof RawString)
164+ return true;
165+ if (value instanceof Collection)
166+ for (Object elt : (Collection)value)
167+ if (containsSpecialValue(elt))
168+ return true;
169+ if (value instanceof Map)
170+ for (Map.Entry<?,?> entry : ((Map<?,?>)value).entrySet())
171+ if (containsSpecialValue(entry.getKey()) || containsSpecialValue(entry.getValue()))
172+ return true;
118173 return false;
119174 }
120175
176+ /**
177+ * Return true if the given value is likely to find a suitable codec
178+ * to be serialized as a query parameter.
179+ * If the value is not serializable, it must be included in the query string.
180+ * Non serializable values include special values such as function calls,
181+ * column names and bind markers, and collections thereof.
182+ * We also don't serialize fixed size number types. The reason is that if we do it, we will
183+ * force a particular size (4 bytes for ints, ...) and for the query builder, we don't want
184+ * users to have to bother with that.
185+ *
186+ * @param value the value to inspect.
187+ * @return true if the value is serializable, false otherwise.
188+ */
189+ static boolean isSerializable(Object value) {
190+ if (containsSpecialValue(value))
191+ return false;
192+ if (value instanceof Number && !(value instanceof BigInteger || value instanceof BigDecimal))
193+ return false;
194+ if (value instanceof Collection)
195+ for (Object elt : (Collection)value)
196+ if (!isSerializable(elt))
197+ return false;
198+ if (value instanceof Map)
199+ for (Map.Entry<?,?> entry : ((Map<?,?>)value).entrySet())
200+ if (!isSerializable(entry.getKey()) || !isSerializable(entry.getValue()))
201+ return false;
202+ return true;
203+ }
204+
121205 static boolean isIdempotent(Object value) {
122206 if(value == null) {
123207 return true;
@@ -143,13 +227,6 @@
143227 return true;
144228 }
145229
146- static boolean isRawValue(Object value) {
147- return value != null
148- && !(value instanceof FCall)
149- && !(value instanceof CName)
150- && !(value instanceof BindMarker);
151- }
152-
153230 static StringBuilder appendName(String name, StringBuilder sb) {
154231 name = name.trim();
155232 // FIXME: checking for token( specifically is uber ugly, we'll need some better solution.
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderExecutionTest.java +2 −2
@@ -89,11 +89,11 @@
8989 @Test(groups = "short")
9090 public void prepareTest() throws Exception {
9191 // Just check we correctly avoid values when there is a bind marker
92- String query = "INSERT INTO foo(a,b,c,d) VALUES ('foo','bar',?,0);";
92+ String query = "INSERT INTO foo (a,b,c,d) VALUES ('foo','bar',?,0);";
9393 BuiltStatement stmt = builder.insertInto("foo").value("a", "foo").value("b", "bar").value("c", bindMarker()).value("d", 0);
9494 assertEquals(stmt.getQueryString(), query);
9595
96- query = "INSERT INTO foo(a,b,c,d) VALUES ('foo','bar',:c,0);";
96+ query = "INSERT INTO foo (a,b,c,d) VALUES ('foo','bar',:c,0);";
9797 stmt = builder.insertInto("foo").value("a", "foo").value("b", "bar").value("c", bindMarker("c")).value("d", 0);
9898 assertEquals(stmt.getQueryString(), query);
9999 }
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderITest.java +3 −3
@@ -143,17 +143,17 @@
143143 String query;
144144 Statement insert;
145145
146- query = "INSERT INTO foo(a) VALUES ('123); --comment');";
146+ query = "INSERT INTO foo (a) VALUES ('123); --comment');";
147147 insert = builder.insertInto("foo")
148148 .value("a", "123); --comment");
149149 assertEquals(insert.toString(), query);
150150
151- query = "INSERT INTO foo(\"a,b\") VALUES (123);";
151+ query = "INSERT INTO foo (\"a,b\") VALUES (123);";
152152 insert = builder.insertInto("foo")
153153 .value("a,b", 123);
154154 assertEquals(insert.toString(), query);
155155
156- query = "INSERT INTO foo(a,b) VALUES ({'2''} space','3','4'},3.4) USING TTL 24 AND TIMESTAMP 42;";
156+ query = "INSERT INTO foo (a,b) VALUES ({'2''} space','3','4'},3.4) USING TTL 24 AND TIMESTAMP 42;";
157157 insert = builder.insertInto("foo").values(new String[]{ "a", "b"}, new Object[]{ new TreeSet<String>(){{ add("2'} space"); add("3"); add("4"); }}, 3.4 }).using(ttl(24)).and(timestamp(42));
158158 assertEquals(insert.toString(), query);
159159 }
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderRoutingKeyTest.java +2 −2
@@ -107,7 +107,7 @@
107107 query = builder.select().from(table).where(eq("k", 42));
108108
109109 batch_query = "BEGIN BATCH ";
110- batch_query += String.format("INSERT INTO %s.test_int(k,a) VALUES (42,1);", keyspace);
110+ batch_query += String.format("INSERT INTO %s.test_int (k,a) VALUES (42,1);", keyspace);
111111 batch_query += String.format("UPDATE %s.test_int USING TTL 400;", keyspace);
112112 batch_query += "APPLY BATCH;";
113113 batch = builder.batch()
@@ -134,7 +134,7 @@
134134 // TODO: rs = session.execute(batch); // Not guaranteed to be valid CQL
135135
136136 batch_query = "BEGIN BATCH USING TIMESTAMP 42 ";
137- batch_query += "INSERT INTO foo.bar(a) VALUES (123);";
137+ batch_query += "INSERT INTO foo.bar (a) VALUES (123);";
138138 batch_query += "APPLY BATCH;";
139139 batch = builder.batch().using(timestamp(42)).add(builder.insertInto("foo", "bar").value("a", 123));
140140 assertEquals(batch.getRoutingKey(), null);
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderTest.java +72 −19
@@ -22,12 +22,11 @@
2222
2323 import com.google.common.collect.ImmutableList;
2424 import com.google.common.collect.ImmutableMap;
25-import org.testng.annotations.BeforeMethod;
25+import com.google.common.collect.Lists;
26+import com.google.common.collect.Sets;
2627 import org.testng.annotations.Test;
2728
2829 import static org.assertj.core.api.Assertions.assertThat;
29-import static org.mockito.Mockito.mock;
30-import static org.mockito.Mockito.when;
3130 import static org.testng.Assert.assertEquals;
3231 import static org.testng.Assert.assertTrue;
3332 import static org.testng.Assert.fail;
@@ -187,7 +186,7 @@
187186 String query;
188187 Statement insert;
189188
190- query = "INSERT INTO foo(a,b,\"C\",d) VALUES (123,'127.0.0.1','foo''bar',{'x':3,'y':2}) USING TIMESTAMP 42 AND TTL 24;";
189+ query = "INSERT INTO foo (a,b,\"C\",d) VALUES (123,'127.0.0.1','foo''bar',{'x':3,'y':2}) USING TIMESTAMP 42 AND TTL 24;";
191190 insert = builder.insertInto("foo")
192191 .value("a", 123)
193192 .value("b", InetAddress.getByName("127.0.0.1"))
@@ -199,13 +198,13 @@
199198 .using(timestamp(42)).and(ttl(24));
200199 assertEquals(insert.toString(), query);
201200
202- query = "INSERT INTO foo(a,b) VALUES (2,null);";
201+ query = "INSERT INTO foo (a,b) VALUES (2,null);";
203202 insert = builder.insertInto("foo")
204203 .value("a", 2)
205204 .value("b", null);
206205 assertEquals(insert.toString(), query);
207206
208- query = "INSERT INTO foo(a,b) VALUES ({2,3,4},3.4) USING TTL 24 AND TIMESTAMP 42;";
207+ query = "INSERT INTO foo (a,b) VALUES ({2,3,4},3.4) USING TTL 24 AND TIMESTAMP 42;";
209208 insert = builder.insertInto("foo").values(new String[]{ "a", "b" }, new Object[]{ new TreeSet<Integer>() {{
210209 add(2);
211210 add(3);
@@ -213,7 +212,7 @@
213212 }}, 3.4 }).using(ttl(24)).and(timestamp(42));
214213 assertEquals(insert.toString(), query);
215214
216- query = "INSERT INTO foo.bar(a,b) VALUES ({2,3,4},3.4) USING TTL ? AND TIMESTAMP ?;";
215+ query = "INSERT INTO foo.bar (a,b) VALUES ({2,3,4},3.4) USING TTL ? AND TIMESTAMP ?;";
217216 insert = builder.insertInto("foo", "bar")
218217 .values(new String[]{ "a", "b" }, new Object[]{ new TreeSet<Integer>() {{
219218 add(2);
@@ -225,7 +224,7 @@
225224 assertEquals(insert.toString(), query);
226225
227226 // commutative result of TIMESTAMP
228- query = "INSERT INTO foo.bar(a,b,c) VALUES ({2,3,4},3.4,123) USING TIMESTAMP 42;";
227+ query = "INSERT INTO foo.bar (a,b,c) VALUES ({2,3,4},3.4,123) USING TIMESTAMP 42;";
229228 insert = builder.insertInto("foo", "bar")
230229 .using(timestamp(42))
231230 .values(new String[]{ "a", "b" }, new Object[]{ new TreeSet<Integer>() {{
@@ -237,7 +236,7 @@
237236 assertEquals(insert.toString(), query);
238237
239238 // commutative result of value() and values()
240- query = "INSERT INTO foo(c,a,b) VALUES (123,{2,3,4},3.4) USING TIMESTAMP 42;";
239+ query = "INSERT INTO foo (c,a,b) VALUES (123,{2,3,4},3.4) USING TIMESTAMP 42;";
241240 insert = builder.insertInto("foo")
242241 .using(timestamp(42))
243242 .value("c", 123)
@@ -256,7 +255,7 @@
256255 }
257256
258257 // CAS test
259- query = "INSERT INTO foo(k,x) VALUES (0,1) IF NOT EXISTS;";
258+ query = "INSERT INTO foo (k,x) VALUES (0,1) IF NOT EXISTS;";
260259 insert = builder.insertInto("foo").value("k", 0).value("x", 1).ifNotExists();
261260 assertEquals(insert.toString(), query);
262261
@@ -416,7 +415,7 @@
416415 Statement batch;
417416
418417 query = "BEGIN BATCH USING TIMESTAMP 42 ";
419- query += "INSERT INTO foo(a,b) VALUES ({2,3,4},3.4);";
418+ query += "INSERT INTO foo (a,b) VALUES ({2,3,4},3.4);";
420419 query += "UPDATE foo SET a[2]='foo',b=[3,2,1]+b,c=c-{'a'} WHERE k=2;";
421420 query += "DELETE a[3],b['foo'],c FROM foo WHERE k=1;";
422421 query += "APPLY BATCH;";
@@ -526,7 +525,7 @@
526525 String query;
527526 Statement insert;
528527
529- query = "INSERT INTO test(k,c) VALUES (0,?);";
528+ query = "INSERT INTO test (k,c) VALUES (0,?);";
530529 insert = builder.insertInto("test")
531530 .value("k", 0)
532531 .value("c", bindMarker());
@@ -619,15 +618,15 @@
619618 String query;
620619 Statement insert;
621620
622- query = "INSERT INTO foo(a) VALUES ('123); --comment');";
621+ query = "INSERT INTO foo (a) VALUES ('123); --comment');";
623622 insert = builder.insertInto("foo").value("a", "123); --comment");
624623 assertEquals(insert.toString(), query);
625624
626- query = "INSERT INTO foo(\"a,b\") VALUES (123);";
625+ query = "INSERT INTO foo (\"a,b\") VALUES (123);";
627626 insert = builder.insertInto("foo").value("a,b", 123);
628627 assertEquals(insert.toString(), query);
629628
630- query = "INSERT INTO foo(a,b) VALUES ({'2''} space','3','4'},3.4) USING TTL 24 AND TIMESTAMP 42;";
629+ query = "INSERT INTO foo (a,b) VALUES ({'2''} space','3','4'},3.4) USING TTL 24 AND TIMESTAMP 42;";
631630 insert = builder.insertInto("foo").values(new String[]{ "a", "b" }, new Object[]{ new TreeSet<String>() {{
632631 add("2'} space");
633632 add("3");
@@ -741,13 +740,13 @@
741740 "SELECT * FROM \"Metrics\".\"epochs\";");
742741
743742 assertEquals(builder.insertInto("Metrics", "epochs").toString(),
744- "INSERT INTO Metrics.epochs() VALUES ();");
743+ "INSERT INTO Metrics.epochs () VALUES ();");
745744 assertEquals(builder.insertInto("Metrics", quote("epochs")).toString(),
746- "INSERT INTO Metrics.\"epochs\"() VALUES ();");
745+ "INSERT INTO Metrics.\"epochs\" () VALUES ();");
747746 assertEquals(builder.insertInto(quote("Metrics"), "epochs").toString(),
748- "INSERT INTO \"Metrics\".epochs() VALUES ();");
747+ "INSERT INTO \"Metrics\".epochs () VALUES ();");
749748 assertEquals(builder.insertInto(quote("Metrics"), quote("epochs")).toString(),
750- "INSERT INTO \"Metrics\".\"epochs\"() VALUES ();");
749+ "INSERT INTO \"Metrics\".\"epochs\" () VALUES ();");
751750 }
752751
753752 @Test(groups = "unit")
@@ -885,4 +884,58 @@
885884 assertThat(actual).isSameAs(expected);
886885 }
887886
887+ @Test(groups = "unit")
888+ @CassandraVersion(major = 2.1)
889+ public void should_serialize_collections_of_serializable_elements() {
890+ Set<UUID> set = Sets.newHashSet(UUID.randomUUID());
891+ List<Date> list = Lists.newArrayList(new Date());
892+ Map<BigInteger, String> map = ImmutableMap.of(new BigInteger("1"), "foo");
893+ BuiltStatement query = builder.insertInto("foo").value("v", set);
894+ assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES (?);");
895+ assertThat(query.getObject(0)).isEqualTo(set);
896+ query = builder.insertInto("foo").value("v", list);
897+ assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES (?);");
898+ assertThat(query.getObject(0)).isEqualTo(list);
899+ query = builder.insertInto("foo").value("v", map);
900+ assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES (?);");
901+ assertThat(query.getObject(0)).isEqualTo(map);
902+ }
903+
904+ @Test(groups = "unit")
905+ @CassandraVersion(major = 2.1)
906+ public void should_not_attempt_to_serialize_function_calls_in_collections() {
907+ BuiltStatement query = builder.insertInto("foo").value("v", Sets.newHashSet(fcall("func", 1)));
908+ assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES ({func(1)});");
909+ assertThat(query.getValues()).isNullOrEmpty();
910+ }
911+
912+ @Test(groups = "unit")
913+ @CassandraVersion(major = 2.1)
914+ public void should_not_attempt_to_serialize_raw_values_in_collections() {
915+ BuiltStatement query = builder.insertInto("foo").value("v", ImmutableMap.of(1, raw("x")));
916+ assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES ({1:x});");
917+ assertThat(query.getValues()).isNullOrEmpty();
918+ }
919+
920+ @Test(groups = "unit")
921+ @CassandraVersion(major = 2.1)
922+ public void should_not_attempt_to_serialize_collections_containing_numbers() {
923+ BuiltStatement query;
924+ // lists
925+ List<Integer> list = Lists.newArrayList(1, 2, 3);
926+ query = builder.insertInto("foo").value("v", list);
927+ assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES ([1,2,3]);");
928+ assertThat(query.hasValues()).isFalse();
929+ // sets
930+ Set<Integer> set = Sets.newHashSet(1, 2, 3);
931+ query = builder.insertInto("foo").value("v", set);
932+ assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES ({1,2,3});");
933+ assertThat(query.hasValues()).isFalse();
934+ // maps
935+ Map<Integer, Float> map = ImmutableMap.of(1, 12.34f);
936+ query = builder.insertInto("foo").value("v", map);
937+ assertThat(query.getQueryString()).isEqualTo("INSERT INTO foo (v) VALUES ({1:12.34});");
938+ assertThat(query.hasValues()).isFalse();
939+ }
940+
888941 }
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderTupleExecutionTest.java +1 −1
@@ -44,7 +44,7 @@
4444
4545 @Test(groups = "short")
4646 public void should_handle_tuple() throws Exception {
47- String query = "INSERT INTO foo(k,x) VALUES (0,(1));";
47+ String query = "INSERT INTO foo (k,x) VALUES (0,(1));";
4848 TupleType tupleType = cluster.getMetadata().newTupleType(cint());
4949 BuiltStatement insert = new QueryBuilder(cluster).insertInto("foo").value("k", 0).value("x", tupleType.newValue(1));
5050 assertEquals(insert.toString(), query);
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderUDTExecutionTest.java +2 −2
@@ -49,7 +49,7 @@
4949 UDTValue udtValue = udtType.newValue().setInt("i", 2).setInet("a", InetAddress.getByName("localhost"));
5050
5151 Statement insert = new QueryBuilder(cluster).insertInto("udtTest").value("k", 1).value("t", udtValue);
52- assertEquals(insert.toString(), "INSERT INTO udtTest(k,t) VALUES (1,{i:2,a:'127.0.0.1'});");
52+ assertEquals(insert.toString(), "INSERT INTO udtTest (k,t) VALUES (1,{i:2,a:'127.0.0.1'});");
5353
5454 session.execute(insert);
5555
@@ -68,7 +68,7 @@
6868 UDTValue udtValue2 = udtType.newValue().setInt("i", 3).setInet("a", InetAddress.getByName("localhost"));
6969
7070 Statement insert = new QueryBuilder(cluster).insertInto("udtTest").value("k", 1).value("l", ImmutableList.of(udtValue));
71- assertThat(insert.toString()).isEqualTo("INSERT INTO udtTest(k,l) VALUES (1,[{i:2,a:'127.0.0.1'}]);");
71+ assertThat(insert.toString()).isEqualTo("INSERT INTO udtTest (k,l) VALUES (1,[{i:2,a:'127.0.0.1'}]);");
7272
7373 session.execute(insert);
7474