-
-
Save gwik/2d793da01a88cd6a5280f4a152f61a44 to your computer and use it in GitHub Desktop.
repro cassandra-rs bug (https://github.com/Metaswitch/cassandra-rs/issues/86)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use cassandra_cpp::*; | |
fn do_work(session: &Session) -> Result<()> { | |
let create_keyspace = stmt!("CREATE KEYSPACE IF NOT EXISTS testks WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 };"); | |
let create_table = stmt!( | |
"CREATE TABLE IF NOT EXISTS testks.repro (first_name text PRIMARY KEY, xxx text, yyy text)" | |
); | |
let truncate_table = stmt!("TRUNCATE testks.repro"); | |
let mut insert_data = stmt!("INSERT INTO testks.repro (first_name, xxx, yyy) VALUES (?, ?, ?)"); | |
let query = stmt!("SELECT * FROM testks.repro;"); | |
session.execute(&create_keyspace).wait()?; | |
session.execute(&create_table).wait()?; | |
session.execute(&truncate_table).wait()?; | |
insert_data.bind_by_name("first_name", "Paul")?; | |
insert_data.bind_by_name("xxx", "aasdf0asdfas8d9f")?; | |
insert_data.bind_by_name("yyy", "b123921381923921939")?; | |
session.execute(&insert_data).wait()?; | |
let result = session.execute(&query).wait()?; | |
let mut found_one = false; | |
for row in result.iter() { | |
found_one = true; | |
let first_name: String = row.get_by_name("first_name")?; | |
let x: String = row.get_by_name("xxx")?; | |
let y: String = row.get_by_name("yyy")?; | |
assert_eq!("Paul".to_string(), first_name); | |
assert_eq!("aasdf0asdfas8d9f".to_string(), x); | |
assert_eq!("b123921381923921939".to_string(), y); | |
} | |
assert!(found_one); | |
Ok(()) | |
} | |
fn main() { | |
let contact_points = "127.0.0.1"; | |
let mut cluster = Cluster::default(); | |
cluster.set_contact_points(contact_points).unwrap(); | |
cluster.set_load_balance_round_robin(); | |
let session = cluster.connect().unwrap(); | |
do_work(&session).unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment