Skip to content

Commit

Permalink
chore: feature gate several things to resolve warnings in WASM build
Browse files Browse the repository at this point in the history
  • Loading branch information
jacek-prisma committed Nov 27, 2024
1 parent ab8a010 commit b5ee534
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions quaint/src/connector/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub trait TransactionCapable: Queryable {
) -> crate::Result<Box<dyn Transaction + 'a>>;
}

#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
macro_rules! impl_default_TransactionCapable {
($t:ty) => {
#[async_trait]
Expand All @@ -130,4 +131,5 @@ macro_rules! impl_default_TransactionCapable {
};
}

#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
pub(crate) use impl_default_TransactionCapable;
21 changes: 13 additions & 8 deletions quaint/src/connector/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub trait Transaction: Queryable {
fn as_queryable(&self) -> &dyn Queryable;
}

#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
pub(crate) struct TransactionOptions {
/// The isolation level to use.
pub(crate) isolation_level: Option<IsolationLevel>,
Expand All @@ -29,6 +30,17 @@ pub(crate) struct TransactionOptions {
pub(crate) isolation_first: bool,
}

#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
impl TransactionOptions {
pub fn new(isolation_level: Option<IsolationLevel>, isolation_first: bool) -> Self {
Self {
isolation_level,
isolation_first,
}
}

Check warning on line 40 in quaint/src/connector/transaction.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/prisma-engines/prisma-engines/quaint/src/connector/transaction.rs
}


/// A default representation of an SQL database transaction. If not commited, a
/// transaction will be rolled back by default when dropped.
///
Expand All @@ -40,6 +52,7 @@ pub struct DefaultTransaction<'a> {
}

impl<'a> DefaultTransaction<'a> {
#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
pub(crate) async fn new(
inner: &'a dyn Queryable,
begin_stmt: &str,
Expand Down Expand Up @@ -196,11 +209,3 @@ impl FromStr for IsolationLevel {
}
}
}
impl TransactionOptions {
pub fn new(isolation_level: Option<IsolationLevel>, isolation_first: bool) -> Self {
Self {
isolation_level,
isolation_first,
}
}
}

0 comments on commit b5ee534

Please sign in to comment.