Skip to content

Commit

Permalink
Upgrade to Scylla 0.11.1 (#44)
Browse files Browse the repository at this point in the history
* Upgrade to Scylla 0.11.1
  • Loading branch information
Jasperav committed Dec 27, 2023
1 parent 6b74c52 commit f6cedf0
Show file tree
Hide file tree
Showing 20 changed files with 218 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scylla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# Locally scylla can be started like so: docker run --name scylla -p 19042:19042 -p 9042:9042 --rm scylladb/scylla
services:
scylladb:
image: scylladb/scylla
image: scylladb/scylla:5.4
ports:
- 9042:9042
- 19042:19042
Expand Down
77 changes: 65 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resolver = "2"

[workspace.package]
edition = "2021"
version = "0.1.20"
version = "0.1.21"
authors = ["Jasper Visser <jasperav@hotmail.com>"]
repository = "https://github.com/Jasperav/catalytic"
readme = "./README.md"
Expand All @@ -19,7 +19,7 @@ categories = ["database"]
license = "MIT"

[workspace.dependencies]
scylla = "0.10.1" # This crate is specifically build for this version
scylla = "0.11.1" # This crate is specifically build for this version
once_cell = "1"
heck = "0.4"
tokio = { version = "1", features = ["time", "rt-multi-thread", "io-util"] }
Expand Down
41 changes: 22 additions & 19 deletions catalytic/src/query_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/// methods, but specific methods, like 'update', 'delete' etc
use crate::Cursor;
use futures_util::{StreamExt, TryStreamExt};
use scylla::_macro_internal::{LegacySerializedValues, SerializeRow};
use scylla::cql_to_rust::FromRowError;
use scylla::frame::value::SerializedValues;
use scylla::frame::value::{SerializeValuesError, ValueList};
use scylla::frame::value::SerializeValuesError;
use scylla::query::Query;
use scylla::transport::errors::QueryError;
use scylla::transport::iterator::TypedRowIterator;
Expand Down Expand Up @@ -199,12 +199,12 @@ impl<T: FromRow> QueryResultUniqueRowExpect<T> {
}
}

pub struct Qv<R: AsRef<str> = &'static str, V: ValueList = SerializedValues> {
pub struct Qv<R: AsRef<str> = &'static str, V: SerializeRow = LegacySerializedValues> {
pub query: R,
pub values: V,
}

impl<R: AsRef<str> + Clone, V: ValueList + Clone> Clone for Qv<R, V> {
impl<R: AsRef<str> + Clone, V: SerializeRow + Clone> Clone for Qv<R, V> {
fn clone(&self) -> Self {
Qv {
query: self.query.clone(),
Expand All @@ -213,15 +213,15 @@ impl<R: AsRef<str> + Clone, V: ValueList + Clone> Clone for Qv<R, V> {
}
}

impl<R: AsRef<str>, V: ValueList> Debug for Qv<R, V> {
impl<R: AsRef<str>, V: SerializeRow> Debug for Qv<R, V> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Qv")
.field("query", &self.query.as_ref())
.finish()
}
}

impl<R: AsRef<str>, V: ValueList> Qv<R, V> {
impl<R: AsRef<str>, V: SerializeRow> Qv<R, V> {
async fn execute(&self, session: &CachingSession) -> ScyllaQueryResult {
let as_ref = self.query.as_ref();

Expand Down Expand Up @@ -339,10 +339,10 @@ impl<R: AsRef<str>, V: ValueList> Qv<R, V> {
macro_rules! simple_qv_holder {
($ ident : ident , $ method : ident) => {
#[derive(Debug)]
pub struct $ident<R: AsRef<str> = &'static str, V: ValueList = SerializedValues> {
pub struct $ident<R: AsRef<str> = &'static str, V: SerializeRow = LegacySerializedValues> {
pub qv: Qv<R, V>,
}
impl<R: AsRef<str>, V: ValueList> $ident<R, V> {
impl<R: AsRef<str>, V: SerializeRow> $ident<R, V> {
pub fn new(qv: Qv<R, V>) -> Self {
Self { qv }
}
Expand All @@ -352,15 +352,15 @@ macro_rules! simple_qv_holder {
}
}

impl<R: AsRef<str>, V: ValueList> Deref for $ident<R, V> {
impl<R: AsRef<str>, V: SerializeRow> Deref for $ident<R, V> {
type Target = Qv<R, V>;

fn deref(&self) -> &Self::Target {
&self.qv
}
}

impl<R: AsRef<str> + Clone, V: ValueList + Clone> Clone for $ident<R, V> {
impl<R: AsRef<str> + Clone, V: SerializeRow + Clone> Clone for $ident<R, V> {
fn clone(&self) -> Self {
$ident::new(self.qv.clone())
}
Expand All @@ -376,27 +376,30 @@ simple_qv_holder!(Truncate, truncate);
macro_rules! read_transform {
($ ident : ident) => {
#[derive(Debug)]
pub struct $ident<T: FromRow, R: AsRef<str> = &'static str, V: ValueList = SerializedValues>
{
pub struct $ident<
T: FromRow,
R: AsRef<str> = &'static str,
V: SerializeRow = LegacySerializedValues,
> {
pub qv: Qv<R, V>,
p: PhantomData<T>,
}

impl<T: FromRow, R: AsRef<str>, V: ValueList> $ident<T, R, V> {
impl<T: FromRow, R: AsRef<str>, V: SerializeRow> $ident<T, R, V> {
pub fn new(qv: Qv<R, V>) -> $ident<T, R, V> {
$ident { qv, p: PhantomData }
}
}

impl<T: FromRow, R: AsRef<str>, V: ValueList> Deref for $ident<T, R, V> {
impl<T: FromRow, R: AsRef<str>, V: SerializeRow> Deref for $ident<T, R, V> {
type Target = Qv<R, V>;

fn deref(&self) -> &Self::Target {
&self.qv
}
}

impl<T: FromRow, R: AsRef<str> + Clone, V: ValueList + Clone> Clone for $ident<T, R, V> {
impl<T: FromRow, R: AsRef<str> + Clone, V: SerializeRow + Clone> Clone for $ident<T, R, V> {
fn clone(&self) -> Self {
$ident::new(self.qv.clone())
}
Expand All @@ -407,7 +410,7 @@ read_transform!(SelectMultiple);
read_transform!(SelectUnique);
read_transform!(SelectUniqueExpect);

impl<T: FromRow, R: AsRef<str>, V: ValueList> SelectUnique<T, R, V> {
impl<T: FromRow, R: AsRef<str>, V: SerializeRow> SelectUnique<T, R, V> {
pub fn expect(self) -> SelectUniqueExpect<T, R, V> {
SelectUniqueExpect::new(self.qv)
}
Expand All @@ -423,7 +426,7 @@ impl<T: FromRow, R: AsRef<str>, V: ValueList> SelectUnique<T, R, V> {
}
}

impl<T: FromRow, R: AsRef<str>, V: ValueList> SelectUniqueExpect<T, R, V> {
impl<T: FromRow, R: AsRef<str>, V: SerializeRow> SelectUniqueExpect<T, R, V> {
pub async fn select(
&self,
session: &CachingSession,
Expand All @@ -435,7 +438,7 @@ impl<T: FromRow, R: AsRef<str>, V: ValueList> SelectUniqueExpect<T, R, V> {
}
}

impl<R: AsRef<str>, V: ValueList> SelectUniqueExpect<Count, R, V> {
impl<R: AsRef<str>, V: SerializeRow> SelectUniqueExpect<Count, R, V> {
pub async fn select_count(
&self,
session: &CachingSession,
Expand All @@ -448,7 +451,7 @@ impl<R: AsRef<str>, V: ValueList> SelectUniqueExpect<Count, R, V> {
}
}

impl<T: FromRow, R: AsRef<str>, V: ValueList> SelectMultiple<T, R, V> {
impl<T: FromRow, R: AsRef<str>, V: SerializeRow> SelectMultiple<T, R, V> {
pub async fn select(
&self,
session: &CachingSession,
Expand Down
6 changes: 3 additions & 3 deletions catalytic/src/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::env_property_reader::{database_url, keyspace, password, username};
use once_cell::sync::Lazy;
use scylla::_macro_internal::SerializeRow;
use scylla::execution_profile::ExecutionProfileBuilder;
use scylla::frame::types::Consistency;
use scylla::frame::value::ValueList;
use scylla::query::Query;
use scylla::{FromRow, IntoTypedRows, Session, SessionBuilder};
use tokio::runtime::{self, Runtime};
Expand All @@ -21,7 +21,7 @@ pub static RUNTIME: Lazy<Runtime> = Lazy::new(|| {

pub fn query_collect_to_vec<Entity: FromRow>(
query: impl Into<Query>,
values: impl ValueList,
values: impl SerializeRow,
) -> Vec<Entity> {
touch_global_connection();

Expand All @@ -38,7 +38,7 @@ pub fn query_collect_to_vec<Entity: FromRow>(
})
}

pub fn query(query: impl Into<Query>, values: impl ValueList) {
pub fn query(query: impl Into<Query>, values: impl SerializeRow) {
touch_global_connection();

block_on(async move { GLOBAL_CONNECTION.query(query, values).await.unwrap() });
Expand Down

0 comments on commit f6cedf0

Please sign in to comment.