Skip to content

Commit

Permalink
Update broken examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nsipplswezey committed Oct 17, 2023
1 parent 68494e4 commit 4644d9f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions examples/compare-tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ async fn main() -> Result<()> {

session
.query(
"CREATE TABLE IF NOT EXISTS ks.t (pk bigint primary key)",
"CREATE TABLE IF NOT EXISTS ks.compare_tokens_example (pk bigint primary key)",
&[],
)
.await?;

let prepared = session.prepare("INSERT INTO ks.t (pk) VALUES (?)").await?;
let prepared = session.prepare("INSERT INTO ks.compare_tokens_example (pk) VALUES (?)").await?;

for pk in (0..100_i64).chain(99840..99936_i64) {
session
.query("INSERT INTO ks.t (pk) VALUES (?)", (pk,))
.query("INSERT INTO ks.compare_tokens_example (pk) VALUES (?)", (pk,))
.await?;

let serialized_pk = (pk,).serialized()?.into_owned();
Expand All @@ -43,7 +43,7 @@ async fn main() -> Result<()> {
);

let qt = session
.query(format!("SELECT token(pk) FROM ks.t where pk = {}", pk), &[])
.query(format!("SELECT token(pk) FROM ks.compare_tokens_example where pk = {}", pk), &[])
.await?
.rows
.unwrap()
Expand Down
8 changes: 4 additions & 4 deletions examples/custom_deserialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ async fn main() -> Result<()> {
session.query("CREATE KEYSPACE IF NOT EXISTS ks WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}", &[]).await?;
session
.query(
"CREATE TABLE IF NOT EXISTS ks.t (pk int PRIMARY KEY, v text)",
"CREATE TABLE IF NOT EXISTS ks.custom_deserialization_test (pk int primary key, v text)",
&[],
)
.await?;

session
.query("INSERT INTO ks.t (pk, v) VALUES (1, 'asdf')", ())
.query("INSERT INTO ks.custom_deserialization_test (pk, v) VALUES (1, 'asdf')", ())
.await?;

// You can implement FromCqlVal for your own types
Expand All @@ -38,7 +38,7 @@ async fn main() -> Result<()> {
}

let (v,) = session
.query("SELECT v FROM ks.t WHERE pk = 1", ())
.query("SELECT v FROM ks.custom_deserialization_test WHERE pk = 1", ())
.await?
.single_row_typed::<(MyType,)>()?;
assert_eq!(v, MyType("asdf".to_owned()));
Expand All @@ -62,7 +62,7 @@ async fn main() -> Result<()> {
impl_from_cql_value_from_method!(MyOtherType, into_my_other_type);

let (v,) = session
.query("SELECT v FROM ks.t WHERE pk = 1", ())
.query("SELECT v FROM ks.custom_deserialization_test WHERE pk = 1", ())
.await?
.single_row_typed::<(MyOtherType,)>()?;
assert_eq!(v, MyOtherType("asdf".to_owned()));
Expand Down
2 changes: 1 addition & 1 deletion examples/execution_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn main() -> Result<()> {
println!("Connecting to {} ...", uri);

let profile1 = ExecutionProfile::builder()
.consistency(Consistency::EachQuorum)
.consistency(Consistency::LocalQuorum)
.serial_consistency(Some(SerialConsistency::Serial))
.request_timeout(Some(Duration::from_secs(42)))
.load_balancing_policy(Arc::new(load_balancing::DefaultPolicy::default()))
Expand Down

0 comments on commit 4644d9f

Please sign in to comment.