Repository: AlexPikalov/cdrs (language: rust)

Issue:
Example for batches with parameters needed
The [current example for batches](https://github.com/AlexPikalov/cdrs/blob/master/examples/batch_queries.rs#L39) does not show how values are passed to batch queries:
```
let batch_query = BatchQueryBuilder::new()
    .add_query_prepared(prepared.id.clone(), vec![])
    .add_query(run, vec![])
    .finalize()
    .unwrap();
```

That would be useful because the way how values are passed to non batched queries does not work for them:
```
let values: Vec<Value> = vec![a.into(),
                                  b.into(),
                                  c.into(),
                                  d.into()];
let execution_params = QueryParamsBuilder::new(Consistency::Any)
          .values(values).finalize();
batch_builder = batch_builder.add_query_prepared(prepared.id.clone(), values);



error[E0308]: mismatched types
  --> src/storing.rs:39:83
   |
39 |             batch_builder = batch_builder.add_query_prepared(prepared.id.clone(), values);
   |                                                                                   ^^^^^^ expected tuple, found struct `cdrs::types::value::Value`
   |
   = note: expected type `std::vec::Vec<(std::option::Option<cdrs::types::CString>, cdrs::types::value::Value)>`
              found type `std::vec::Vec<cdrs::types::value::Value>`
```



Discussion / hints:
Hello @maklemenz
I agree this part is missed. I'll try to add such example for 1.x.x version ASAP. Meanwhile you can check out how process of passing values will look like in version 2.0.0 that I'm working on. https://github.com/AlexPikalov/cdrs/blob/v2.0.0/examples/version_2.rs#L55 I plan to implement something similar for query batching as well
As for upcoming version 2, example for batches with parameters could be found [here](https://github.com/AlexPikalov/cdrs/blob/v2.0.0/examples/prepare_batch_execute.rs#L75).

Fix patch:
diff --git a/examples/batch_queries.rs b/examples/batch_queries.rs
index 1abeab5..32d954f 100644
--- a/examples/batch_queries.rs
+++ b/examples/batch_queries.rs
@@ -1,4 +1,3 @@
-
 extern crate cdrs;
 
 use cdrs::client::CDRS;
@@ -6,41 +5,54 @@ use cdrs::query::BatchQueryBuilder;
 use cdrs::authenticators::PasswordAuthenticator;
 use cdrs::compression::Compression;
 use cdrs::transport::TransportTcp;
+use cdrs::query::QueryBuilder;
+
 // default credentials
 const _USER: &'static str = "cassandra";
 const _PASS: &'static str = "cassandra";
 const _ADDR: &'static str = "127.0.0.1:9042";
 
-/// First create a keyspace 'keyspace'.
-/// Then create a new table of integers:
-/// CREATE TABLE keyspace.integers (integer int PRIMARY KEY);
-
-
 fn main() {
     let authenticator = PasswordAuthenticator::new(_USER, _PASS);
     let tcp_transport = TransportTcp::new(_ADDR).unwrap();
     let client = CDRS::new(tcp_transport, authenticator);
     let session = client.start(Compression::None).unwrap();
 
-    let prepare_query = "INSERT INTO keyspace.integers (integer) VALUES (1);".to_string();
+    let create_ks_query = "CREATE KEYSPACE IF NOT EXISTS ks
+        WITH REPLICATION = { 
+        'class' : 'SimpleStrategy', 
+        'replication_factor' : 1 
+        };";
+    let create_table_query = "CREATE TABLE IF NOT EXISTS ks.integers (integer int PRIMARY KEY);";
+    let prepare_query = "INSERT INTO ks.integers (integer) VALUES (1);".to_string();
+
     let with_tracing = false;
     let with_warnings = false;
 
-    let prepared = session
-        .prepare(prepare_query, with_tracing, with_warnings)
-        .unwrap()
-        .get_body()
-        .unwrap()
-        .into_prepared()
-        .unwrap();
-
-    let run = "INSERT INTO keyspace.integers (integer) VALUES (2);".to_string();
-
-    let batch_query = BatchQueryBuilder::new()
-        .add_query_prepared(prepared.id.clone(), vec![])
-        .add_query(run, vec![])
-        .finalize()
-        .unwrap();
+    let create_table_query = "CREATE TABLE IF NOT EXISTS ks.integers (integer int PRIMARY KEY);";
+    session.query(QueryBuilder::new(create_ks_query).finalize(),
+                  with_tracing,
+                  with_warnings)
+           .expect("create keyspace");
+
+    session.query(QueryBuilder::new(create_table_query).finalize(),
+                  with_tracing,
+                  with_warnings)
+           .expect("create table");
+
+    let prepared = session.prepare(prepare_query, with_tracing, with_warnings)
+                          .unwrap()
+                          .get_body()
+                          .unwrap()
+                          .into_prepared()
+                          .unwrap();
+
+    let run = "INSERT INTO ks.integers (integer) VALUES (?);".to_string();
+
+    let batch_query = BatchQueryBuilder::new().add_query_prepared(prepared.id.clone(), vec![])
+                                              .add_query(run, vec![(None, 2i32.into())])
+                                              .finalize()
+                                              .unwrap();
 
     let batched = session.batch(batch_query, false, false).unwrap();
 


Test patch: