@@ -101,14 +101,10 @@ async fn test_batch_of_bound_statements() {
101
101
102
102
let prepared = prepare_insert_statement ( & session, & ks, & test_name) . await ;
103
103
let mut batch = Batch :: new ( BatchType :: Unlogged ) ;
104
- let mut batch_values: Vec < Vec < CqlValue > > = Vec :: with_capacity ( BATCH_COUNT ) ;
104
+ let mut batch_values: Vec < _ > = Vec :: with_capacity ( BATCH_COUNT ) ;
105
105
for i in 0 ..BATCH_COUNT as i32 {
106
106
batch. append_statement ( prepared. clone ( ) ) ;
107
- batch_values. push ( vec ! [
108
- CqlValue :: Text ( test_name. clone( ) ) ,
109
- CqlValue :: Int ( i) ,
110
- CqlValue :: Int ( i + 1 ) ,
111
- ] ) ;
107
+ batch_values. push ( ( test_name. as_str ( ) , i, i + 1 ) ) ;
112
108
}
113
109
session. batch ( & batch, batch_values) . await . unwrap ( ) ;
114
110
verify_batch_insert ( & session, & ks, & test_name, BATCH_COUNT ) . await ;
@@ -128,11 +124,7 @@ async fn test_prepared_batch() {
128
124
) ;
129
125
for i in 0 ..BATCH_COUNT as i32 {
130
126
batch. append_statement ( Query :: new ( query_str. clone ( ) ) ) ;
131
- batch_values. push ( vec ! [
132
- CqlValue :: Text ( test_name. clone( ) ) ,
133
- CqlValue :: Int ( i) ,
134
- CqlValue :: Int ( i + 1 ) ,
135
- ] ) ;
127
+ batch_values. push ( ( & test_name, i, i + 1 ) ) ;
136
128
}
137
129
let prepared_batch = session. prepare_batch ( & batch) . await . unwrap ( ) ;
138
130
session. batch ( & prepared_batch, batch_values) . await . unwrap ( ) ;
@@ -150,11 +142,7 @@ async fn test_batch_of_bound_statements_with_unset_values() {
150
142
let mut batch1_values = Vec :: with_capacity ( BATCH_COUNT ) ;
151
143
for i in 0 ..BATCH_COUNT as i32 {
152
144
batch1. append_statement ( prepared. clone ( ) ) ;
153
- batch1_values. push ( vec ! [
154
- CqlValue :: Text ( test_name. clone( ) ) ,
155
- CqlValue :: Int ( i) ,
156
- CqlValue :: Int ( i + 1 ) ,
157
- ] ) ;
145
+ batch1_values. push ( ( test_name. as_str ( ) , i, i + 1 ) ) ;
158
146
}
159
147
session. batch ( & batch1, batch1_values) . await . unwrap ( ) ;
160
148
@@ -164,17 +152,17 @@ async fn test_batch_of_bound_statements_with_unset_values() {
164
152
for i in 0 ..BATCH_COUNT as i32 {
165
153
batch2. append_statement ( prepared. clone ( ) ) ;
166
154
if i % 20 == 0 {
167
- batch2_values. push ( vec ! [
168
- MaybeUnset :: Set ( CqlValue :: Text ( test_name. clone ( ) ) ) ,
169
- MaybeUnset :: Set ( CqlValue :: Int ( i ) ) ,
155
+ batch2_values. push ( (
156
+ MaybeUnset :: Set ( & test_name) ,
157
+ MaybeUnset :: Set ( i ) ,
170
158
MaybeUnset :: Unset ,
171
- ] ) ;
159
+ ) ) ;
172
160
} else {
173
- batch2_values. push ( vec ! [
174
- MaybeUnset :: Set ( CqlValue :: Text ( test_name. clone ( ) ) ) ,
175
- MaybeUnset :: Set ( CqlValue :: Int ( i ) ) ,
176
- MaybeUnset :: Set ( CqlValue :: Int ( i + 2 ) ) ,
177
- ] ) ;
161
+ batch2_values. push ( (
162
+ MaybeUnset :: Set ( & test_name) ,
163
+ MaybeUnset :: Set ( i ) ,
164
+ MaybeUnset :: Set ( i + 2 ) ,
165
+ ) ) ;
178
166
}
179
167
}
180
168
session. batch ( & batch2, batch2_values) . await . unwrap ( ) ;
@@ -286,11 +274,7 @@ async fn test_cas_batch() {
286
274
let mut batch_values = Vec :: with_capacity ( BATCH_COUNT ) ;
287
275
for i in 0 ..BATCH_COUNT as i32 {
288
276
batch. append_statement ( prepared. clone ( ) ) ;
289
- batch_values. push ( vec ! [
290
- CqlValue :: Text ( test_name. clone( ) ) ,
291
- CqlValue :: Int ( i) ,
292
- CqlValue :: Int ( i + 1 ) ,
293
- ] ) ;
277
+ batch_values. push ( ( & test_name, i, i + 1 ) ) ;
294
278
}
295
279
let result = session. batch ( & batch, batch_values. clone ( ) ) . await . unwrap ( ) ;
296
280
let ( applied, ) : ( bool , ) = result
@@ -326,7 +310,7 @@ async fn test_counter_batch() {
326
310
let query_str = format ! ( "UPDATE {}.counter{} SET c = c + ? WHERE k0 = ?" , ks, i) ;
327
311
let prepared = session. prepare ( Query :: new ( query_str) ) . await . unwrap ( ) ;
328
312
batch. append_statement ( prepared) ;
329
- batch_values. push ( vec ! [ CqlValue :: Int ( i ) , CqlValue :: Text ( test_name. clone ( ) ) ] ) ;
313
+ batch_values. push ( ( i , & test_name) ) ;
330
314
}
331
315
session. batch ( & batch, batch_values) . await . unwrap ( ) ;
332
316
@@ -354,12 +338,12 @@ async fn test_fail_logged_batch_with_counter_increment() {
354
338
create_counter_tables ( & session, & ks) . await ;
355
339
356
340
let mut batch = Batch :: new ( BatchType :: Logged ) ;
357
- let mut batch_values: Vec < Vec < CqlValue > > = Vec :: with_capacity ( 3 ) ;
341
+ let mut batch_values: Vec < _ > = Vec :: with_capacity ( 3 ) ;
358
342
for i in 1 ..=3 {
359
343
let query_str = format ! ( "UPDATE {}.counter{} SET c = c + ? WHERE k0 = ?" , ks, i) ;
360
344
let prepared = session. prepare ( Query :: new ( query_str) ) . await . unwrap ( ) ;
361
345
batch. append_statement ( prepared) ;
362
- batch_values. push ( vec ! [ CqlValue :: Int ( i ) , CqlValue :: Text ( test_name. clone ( ) ) ] ) ;
346
+ batch_values. push ( ( i , & test_name) ) ;
363
347
}
364
348
let err = session. batch ( & batch, batch_values) . await . unwrap_err ( ) ;
365
349
assert_matches ! (
0 commit comments