From c987dceb3895fa57f0e16fa84d72d217fd186673 Mon Sep 17 00:00:00 2001 From: Miguel Fernandez Date: Wed, 15 Nov 2023 12:51:00 +0100 Subject: [PATCH 1/8] WIP: refactor mysql module to flatten its structure --- quaint/src/connector.rs | 4 ++-- quaint/src/connector/mysql.rs | 11 +++++++---- quaint/src/connector/mysql/{wasm => }/error.rs | 0 quaint/src/connector/mysql/native/error.rs | 2 +- quaint/src/connector/mysql/native/mod.rs | 2 +- quaint/src/connector/mysql/{wasm/common.rs => url.rs} | 0 quaint/src/connector/mysql/wasm/mod.rs | 6 ------ 7 files changed, 11 insertions(+), 14 deletions(-) rename quaint/src/connector/mysql/{wasm => }/error.rs (100%) rename quaint/src/connector/mysql/{wasm/common.rs => url.rs} (100%) delete mode 100644 quaint/src/connector/mysql/wasm/mod.rs diff --git a/quaint/src/connector.rs b/quaint/src/connector.rs index 7903d23931c0..a2ee455fee22 100644 --- a/quaint/src/connector.rs +++ b/quaint/src/connector.rs @@ -38,10 +38,10 @@ pub use postgres::wasm::common::*; #[cfg(feature = "mysql")] pub(crate) mod mysql; +#[cfg(feature = "mysql")] +pub use mysql::*; #[cfg(feature = "mysql-native")] pub use mysql::native::*; -#[cfg(feature = "mysql")] -pub use mysql::wasm::common::*; #[cfg(feature = "sqlite")] pub(crate) mod sqlite; diff --git a/quaint/src/connector/mysql.rs b/quaint/src/connector/mysql.rs index 1e52af6a83a0..0834be88949e 100644 --- a/quaint/src/connector/mysql.rs +++ b/quaint/src/connector/mysql.rs @@ -1,8 +1,11 @@ -pub use wasm::common::MysqlUrl; -pub use wasm::error::MysqlError; +//! Wasm-compatible definitions for the MySQL connector. +//! This module is only available with the `mysql` feature. +pub mod error; +pub(crate) mod url; -#[cfg(feature = "mysql")] -pub(crate) mod wasm; +pub use error::MysqlError; +pub use url::MysqlUrl; #[cfg(feature = "mysql-native")] pub(crate) mod native; + diff --git a/quaint/src/connector/mysql/wasm/error.rs b/quaint/src/connector/mysql/error.rs similarity index 100% rename from quaint/src/connector/mysql/wasm/error.rs rename to quaint/src/connector/mysql/error.rs diff --git a/quaint/src/connector/mysql/native/error.rs b/quaint/src/connector/mysql/native/error.rs index e00ff1e0aa74..89c21fb706f6 100644 --- a/quaint/src/connector/mysql/native/error.rs +++ b/quaint/src/connector/mysql/native/error.rs @@ -1,5 +1,5 @@ use crate::{ - connector::mysql::wasm::error::MysqlError, + connector::mysql::error::MysqlError, error::{Error, ErrorKind}, }; use mysql_async as my; diff --git a/quaint/src/connector/mysql/native/mod.rs b/quaint/src/connector/mysql/native/mod.rs index e72a2c47a9a1..7a95ee47b614 100644 --- a/quaint/src/connector/mysql/native/mod.rs +++ b/quaint/src/connector/mysql/native/mod.rs @@ -4,7 +4,7 @@ mod conversion; mod error; -pub(crate) use crate::connector::mysql::wasm::common::MysqlUrl; +pub(crate) use crate::connector::mysql::MysqlUrl; use crate::connector::{timeout, IsolationLevel}; use crate::{ diff --git a/quaint/src/connector/mysql/wasm/common.rs b/quaint/src/connector/mysql/url.rs similarity index 100% rename from quaint/src/connector/mysql/wasm/common.rs rename to quaint/src/connector/mysql/url.rs diff --git a/quaint/src/connector/mysql/wasm/mod.rs b/quaint/src/connector/mysql/wasm/mod.rs deleted file mode 100644 index 4f73f82031d5..000000000000 --- a/quaint/src/connector/mysql/wasm/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Wasm-compatible definitions for the MySQL connector. -//! This module is only available with the `mysql` feature. -pub(crate) mod common; -pub mod error; - -pub use common::MysqlUrl; From 626bc1ef904d0e46fec7046a64cb3927889b6452 Mon Sep 17 00:00:00 2001 From: jkomyno Date: Wed, 15 Nov 2023 13:17:23 +0100 Subject: [PATCH 2/8] feat(quaint): flatten mssql connector module --- quaint/src/connector.rs | 6 +++--- quaint/src/connector/mssql.rs | 7 ++++--- quaint/src/connector/mssql/native/mod.rs | 2 +- quaint/src/connector/mssql/{wasm/common.rs => url.rs} | 0 quaint/src/connector/mssql/wasm/mod.rs | 5 ----- quaint/src/connector/mysql.rs | 1 - 6 files changed, 8 insertions(+), 13 deletions(-) rename quaint/src/connector/mssql/{wasm/common.rs => url.rs} (100%) delete mode 100644 quaint/src/connector/mssql/wasm/mod.rs diff --git a/quaint/src/connector.rs b/quaint/src/connector.rs index a2ee455fee22..97643978228b 100644 --- a/quaint/src/connector.rs +++ b/quaint/src/connector.rs @@ -38,10 +38,10 @@ pub use postgres::wasm::common::*; #[cfg(feature = "mysql")] pub(crate) mod mysql; -#[cfg(feature = "mysql")] -pub use mysql::*; #[cfg(feature = "mysql-native")] pub use mysql::native::*; +#[cfg(feature = "mysql")] +pub use mysql::*; #[cfg(feature = "sqlite")] pub(crate) mod sqlite; @@ -55,4 +55,4 @@ pub(crate) mod mssql; #[cfg(feature = "mssql-native")] pub use mssql::native::*; #[cfg(feature = "mssql")] -pub use mssql::wasm::common::*; +pub use mssql::*; diff --git a/quaint/src/connector/mssql.rs b/quaint/src/connector/mssql.rs index c83b5f1f7266..09f589192676 100644 --- a/quaint/src/connector/mssql.rs +++ b/quaint/src/connector/mssql.rs @@ -1,7 +1,8 @@ -pub use wasm::common::MssqlUrl; +//! Wasm-compatible definitions for the MSSQL connector. +//! This module is only available with the `mssql` feature. +pub(crate) mod url; -#[cfg(feature = "mssql")] -pub(crate) mod wasm; +pub use url::MssqlUrl; #[cfg(feature = "mssql-native")] pub(crate) mod native; diff --git a/quaint/src/connector/mssql/native/mod.rs b/quaint/src/connector/mssql/native/mod.rs index 8458935814b4..d7052d5e5180 100644 --- a/quaint/src/connector/mssql/native/mod.rs +++ b/quaint/src/connector/mssql/native/mod.rs @@ -4,7 +4,7 @@ mod conversion; mod error; -pub(crate) use crate::connector::mssql::wasm::common::MssqlUrl; +pub(crate) use crate::connector::mssql::MssqlUrl; use crate::connector::{timeout, IsolationLevel, Transaction, TransactionOptions}; use crate::{ diff --git a/quaint/src/connector/mssql/wasm/common.rs b/quaint/src/connector/mssql/url.rs similarity index 100% rename from quaint/src/connector/mssql/wasm/common.rs rename to quaint/src/connector/mssql/url.rs diff --git a/quaint/src/connector/mssql/wasm/mod.rs b/quaint/src/connector/mssql/wasm/mod.rs deleted file mode 100644 index 5a25a32836c2..000000000000 --- a/quaint/src/connector/mssql/wasm/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! Wasm-compatible definitions for the MSSQL connector. -//! This module is only available with the `mssql` feature. -pub(crate) mod common; - -pub use common::MssqlUrl; diff --git a/quaint/src/connector/mysql.rs b/quaint/src/connector/mysql.rs index 0834be88949e..5ca2c3551f29 100644 --- a/quaint/src/connector/mysql.rs +++ b/quaint/src/connector/mysql.rs @@ -8,4 +8,3 @@ pub use url::MysqlUrl; #[cfg(feature = "mysql-native")] pub(crate) mod native; - From a9f8ba841de6f1715b6e1002f67d22a3b60c5c6d Mon Sep 17 00:00:00 2001 From: jkomyno Date: Wed, 15 Nov 2023 13:23:19 +0100 Subject: [PATCH 3/8] feat(quaint): flatten postgres connector module --- quaint/src/connector.rs | 2 +- quaint/src/connector/mysql.rs | 2 +- quaint/src/connector/postgres.rs | 10 ++++++---- quaint/src/connector/postgres/{wasm => }/error.rs | 0 quaint/src/connector/postgres/native/error.rs | 2 +- quaint/src/connector/postgres/native/mod.rs | 6 +++--- .../src/connector/postgres/{wasm/common.rs => url.rs} | 0 quaint/src/connector/postgres/wasm/mod.rs | 6 ------ 8 files changed, 12 insertions(+), 16 deletions(-) rename quaint/src/connector/postgres/{wasm => }/error.rs (100%) rename quaint/src/connector/postgres/{wasm/common.rs => url.rs} (100%) delete mode 100644 quaint/src/connector/postgres/wasm/mod.rs diff --git a/quaint/src/connector.rs b/quaint/src/connector.rs index 97643978228b..82b1437b6c03 100644 --- a/quaint/src/connector.rs +++ b/quaint/src/connector.rs @@ -34,7 +34,7 @@ pub(crate) mod postgres; #[cfg(feature = "postgresql-native")] pub use postgres::native::*; #[cfg(feature = "postgresql")] -pub use postgres::wasm::common::*; +pub use postgres::*; #[cfg(feature = "mysql")] pub(crate) mod mysql; diff --git a/quaint/src/connector/mysql.rs b/quaint/src/connector/mysql.rs index 5ca2c3551f29..23fed3c70bd3 100644 --- a/quaint/src/connector/mysql.rs +++ b/quaint/src/connector/mysql.rs @@ -1,6 +1,6 @@ //! Wasm-compatible definitions for the MySQL connector. //! This module is only available with the `mysql` feature. -pub mod error; +pub(crate) mod error; pub(crate) mod url; pub use error::MysqlError; diff --git a/quaint/src/connector/postgres.rs b/quaint/src/connector/postgres.rs index 73a8547b8a65..71d40e71ba0f 100644 --- a/quaint/src/connector/postgres.rs +++ b/quaint/src/connector/postgres.rs @@ -1,8 +1,10 @@ -pub use wasm::common::PostgresUrl; -pub use wasm::error::PostgresError; +//! Wasm-compatible definitions for the PostgreSQL connector. +//! This module is only available with the `postgresql` feature. +pub(crate) mod error; +pub(crate) mod url; -#[cfg(feature = "postgresql")] -pub(crate) mod wasm; +pub use error::PostgresError; +pub use url::{PostgresFlavour, PostgresUrl}; #[cfg(feature = "postgresql-native")] pub(crate) mod native; diff --git a/quaint/src/connector/postgres/wasm/error.rs b/quaint/src/connector/postgres/error.rs similarity index 100% rename from quaint/src/connector/postgres/wasm/error.rs rename to quaint/src/connector/postgres/error.rs diff --git a/quaint/src/connector/postgres/native/error.rs b/quaint/src/connector/postgres/native/error.rs index 05b792e27900..c353e397705c 100644 --- a/quaint/src/connector/postgres/native/error.rs +++ b/quaint/src/connector/postgres/native/error.rs @@ -1,7 +1,7 @@ use tokio_postgres::error::DbError; use crate::{ - connector::postgres::wasm::error::PostgresError, + connector::postgres::error::PostgresError, error::{Error, ErrorKind}, }; diff --git a/quaint/src/connector/postgres/native/mod.rs b/quaint/src/connector/postgres/native/mod.rs index fbb4760ed19f..5dbf67a91cdf 100644 --- a/quaint/src/connector/postgres/native/mod.rs +++ b/quaint/src/connector/postgres/native/mod.rs @@ -4,8 +4,8 @@ mod conversion; mod error; -pub(crate) use crate::connector::postgres::wasm::common::PostgresUrl; -use crate::connector::postgres::wasm::common::{Hidden, SslAcceptMode, SslParams}; +pub(crate) use crate::connector::postgres::url::PostgresUrl; +use crate::connector::postgres::url::{Hidden, SslAcceptMode, SslParams}; use crate::connector::{timeout, IsolationLevel, Transaction}; use crate::{ @@ -670,7 +670,7 @@ fn is_safe_identifier(ident: &str) -> bool { #[cfg(test)] mod tests { use super::*; - pub(crate) use crate::connector::postgres::wasm::common::PostgresFlavour; + pub(crate) use crate::connector::postgres::url::PostgresFlavour; use crate::tests::test_api::postgres::CONN_STR; use crate::tests::test_api::CRDB_CONN_STR; use crate::{connector::Queryable, error::*, single::Quaint}; diff --git a/quaint/src/connector/postgres/wasm/common.rs b/quaint/src/connector/postgres/url.rs similarity index 100% rename from quaint/src/connector/postgres/wasm/common.rs rename to quaint/src/connector/postgres/url.rs diff --git a/quaint/src/connector/postgres/wasm/mod.rs b/quaint/src/connector/postgres/wasm/mod.rs deleted file mode 100644 index 859de8f6fd3c..000000000000 --- a/quaint/src/connector/postgres/wasm/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Wasm-compatible definitions for the Postgres connector. -//! This module is only available with the `postgresql` feature. -pub(crate) mod common; -pub mod error; - -pub use common::PostgresUrl; From 3c1a1008c915f1baae29c39dbc82f55fb6b0945a Mon Sep 17 00:00:00 2001 From: jkomyno Date: Wed, 15 Nov 2023 13:28:58 +0100 Subject: [PATCH 4/8] feat(quaint): flatten sqlite connector module --- quaint/src/connector.rs | 2 +- quaint/src/connector/sqlite.rs | 10 +++++++--- quaint/src/connector/sqlite/{wasm => }/error.rs | 0 quaint/src/connector/sqlite/{wasm => }/ffi.rs | 0 quaint/src/connector/sqlite/native/error.rs | 2 +- quaint/src/connector/sqlite/native/mod.rs | 2 +- .../src/connector/sqlite/{wasm/common.rs => params.rs} | 0 quaint/src/connector/sqlite/wasm/mod.rs | 5 ----- 8 files changed, 10 insertions(+), 11 deletions(-) rename quaint/src/connector/sqlite/{wasm => }/error.rs (100%) rename quaint/src/connector/sqlite/{wasm => }/ffi.rs (100%) rename quaint/src/connector/sqlite/{wasm/common.rs => params.rs} (100%) delete mode 100644 quaint/src/connector/sqlite/wasm/mod.rs diff --git a/quaint/src/connector.rs b/quaint/src/connector.rs index 82b1437b6c03..dddb3c953ad7 100644 --- a/quaint/src/connector.rs +++ b/quaint/src/connector.rs @@ -48,7 +48,7 @@ pub(crate) mod sqlite; #[cfg(feature = "sqlite-native")] pub use sqlite::native::*; #[cfg(feature = "sqlite")] -pub use sqlite::wasm::common::*; +pub use sqlite::*; #[cfg(feature = "mssql")] pub(crate) mod mssql; diff --git a/quaint/src/connector/sqlite.rs b/quaint/src/connector/sqlite.rs index 45611aab9357..c59c947b8dc1 100644 --- a/quaint/src/connector/sqlite.rs +++ b/quaint/src/connector/sqlite.rs @@ -1,7 +1,11 @@ -pub use wasm::error::SqliteError; +//! Wasm-compatible definitions for the SQLite connector. +//! This module is only available with the `sqlite` feature. +pub(crate) mod error; +mod ffi; +pub(crate) mod params; -#[cfg(feature = "sqlite")] -pub(crate) mod wasm; +pub use error::SqliteError; +pub use params::*; #[cfg(feature = "sqlite-native")] pub(crate) mod native; diff --git a/quaint/src/connector/sqlite/wasm/error.rs b/quaint/src/connector/sqlite/error.rs similarity index 100% rename from quaint/src/connector/sqlite/wasm/error.rs rename to quaint/src/connector/sqlite/error.rs diff --git a/quaint/src/connector/sqlite/wasm/ffi.rs b/quaint/src/connector/sqlite/ffi.rs similarity index 100% rename from quaint/src/connector/sqlite/wasm/ffi.rs rename to quaint/src/connector/sqlite/ffi.rs diff --git a/quaint/src/connector/sqlite/native/error.rs b/quaint/src/connector/sqlite/native/error.rs index d09e2959ce28..51b2417ed821 100644 --- a/quaint/src/connector/sqlite/native/error.rs +++ b/quaint/src/connector/sqlite/native/error.rs @@ -1,4 +1,4 @@ -use crate::connector::sqlite::wasm::error::SqliteError; +use crate::connector::sqlite::error::SqliteError; use crate::error::*; diff --git a/quaint/src/connector/sqlite/native/mod.rs b/quaint/src/connector/sqlite/native/mod.rs index bdf5c473fd4d..4b686f5968d6 100644 --- a/quaint/src/connector/sqlite/native/mod.rs +++ b/quaint/src/connector/sqlite/native/mod.rs @@ -4,7 +4,7 @@ mod conversion; mod error; -use crate::connector::sqlite::wasm::common::SqliteParams; +use crate::connector::sqlite::params::SqliteParams; use crate::connector::IsolationLevel; pub use rusqlite::{params_from_iter, version as sqlite_version}; diff --git a/quaint/src/connector/sqlite/wasm/common.rs b/quaint/src/connector/sqlite/params.rs similarity index 100% rename from quaint/src/connector/sqlite/wasm/common.rs rename to quaint/src/connector/sqlite/params.rs diff --git a/quaint/src/connector/sqlite/wasm/mod.rs b/quaint/src/connector/sqlite/wasm/mod.rs deleted file mode 100644 index 662237af30a1..000000000000 --- a/quaint/src/connector/sqlite/wasm/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! Wasm-compatible definitions for the SQLite connector. -//! This module is only available with the `sqlite` feature. -pub(crate) mod common; -pub mod error; -mod ffi; From 7f4c8f943142d45340dbd2c4c621093998130a72 Mon Sep 17 00:00:00 2001 From: jkomyno Date: Wed, 15 Nov 2023 13:30:47 +0100 Subject: [PATCH 5/8] chore(quaint): export all public definitions in connector "url" modules --- quaint/src/connector/mssql.rs | 2 +- quaint/src/connector/mysql.rs | 2 +- quaint/src/connector/postgres.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/quaint/src/connector/mssql.rs b/quaint/src/connector/mssql.rs index 09f589192676..e18b68fb2ce1 100644 --- a/quaint/src/connector/mssql.rs +++ b/quaint/src/connector/mssql.rs @@ -2,7 +2,7 @@ //! This module is only available with the `mssql` feature. pub(crate) mod url; -pub use url::MssqlUrl; +pub use url::*; #[cfg(feature = "mssql-native")] pub(crate) mod native; diff --git a/quaint/src/connector/mysql.rs b/quaint/src/connector/mysql.rs index 23fed3c70bd3..0dc504dd2d11 100644 --- a/quaint/src/connector/mysql.rs +++ b/quaint/src/connector/mysql.rs @@ -4,7 +4,7 @@ pub(crate) mod error; pub(crate) mod url; pub use error::MysqlError; -pub use url::MysqlUrl; +pub use url::*; #[cfg(feature = "mysql-native")] pub(crate) mod native; diff --git a/quaint/src/connector/postgres.rs b/quaint/src/connector/postgres.rs index 71d40e71ba0f..d1694108a1b7 100644 --- a/quaint/src/connector/postgres.rs +++ b/quaint/src/connector/postgres.rs @@ -4,7 +4,7 @@ pub(crate) mod error; pub(crate) mod url; pub use error::PostgresError; -pub use url::{PostgresFlavour, PostgresUrl}; +pub use url::*; #[cfg(feature = "postgresql-native")] pub(crate) mod native; From 95a4e28c89a1cda3c7bdf6f15b7ae543ae5da780 Mon Sep 17 00:00:00 2001 From: jkomyno Date: Wed, 15 Nov 2023 17:06:22 +0100 Subject: [PATCH 6/8] chore(quaint): refactor tests for connectors, addressing feedback --- quaint/src/connector/mssql/native/mod.rs | 17 -- quaint/src/connector/mysql/native/mod.rs | 83 -------- quaint/src/connector/mysql/url.rs | 83 ++++++++ quaint/src/connector/postgres/native/mod.rs | 215 +------------------ quaint/src/connector/postgres/url.rs | 223 ++++++++++++++++++++ quaint/src/connector/sqlite/native/mod.rs | 21 -- quaint/src/connector/sqlite/params.rs | 26 +++ 7 files changed, 333 insertions(+), 335 deletions(-) diff --git a/quaint/src/connector/mssql/native/mod.rs b/quaint/src/connector/mssql/native/mod.rs index d7052d5e5180..d22aa7a15dd6 100644 --- a/quaint/src/connector/mssql/native/mod.rs +++ b/quaint/src/connector/mssql/native/mod.rs @@ -237,20 +237,3 @@ impl Queryable for Mssql { true } } - -#[cfg(test)] -mod tests { - use crate::tests::test_api::mssql::CONN_STR; - use crate::{error::*, single::Quaint}; - - #[tokio::test] - async fn should_map_wrong_credentials_error() { - let url = CONN_STR.replace("user=SA", "user=WRONG"); - - let res = Quaint::new(url.as_str()).await; - assert!(res.is_err()); - - let err = res.unwrap_err(); - assert!(matches!(err.kind(), ErrorKind::AuthenticationFailed { user } if user == &Name::available("WRONG"))); - } -} diff --git a/quaint/src/connector/mysql/native/mod.rs b/quaint/src/connector/mysql/native/mod.rs index 7a95ee47b614..fdcc3a6276d1 100644 --- a/quaint/src/connector/mysql/native/mod.rs +++ b/quaint/src/connector/mysql/native/mod.rs @@ -295,86 +295,3 @@ impl Queryable for Mysql { true } } - -#[cfg(test)] -mod tests { - use super::MysqlUrl; - use crate::tests::test_api::mysql::CONN_STR; - use crate::{error::*, single::Quaint}; - use url::Url; - - #[test] - fn should_parse_socket_url() { - let url = MysqlUrl::new(Url::parse("mysql://root@localhost/dbname?socket=(/tmp/mysql.sock)").unwrap()).unwrap(); - assert_eq!("dbname", url.dbname()); - assert_eq!(&Some(String::from("/tmp/mysql.sock")), url.socket()); - } - - #[test] - fn should_parse_prefer_socket() { - let url = - MysqlUrl::new(Url::parse("mysql://root:root@localhost:3307/testdb?prefer_socket=false").unwrap()).unwrap(); - assert!(!url.prefer_socket().unwrap()); - } - - #[test] - fn should_parse_sslaccept() { - let url = - MysqlUrl::new(Url::parse("mysql://root:root@localhost:3307/testdb?sslaccept=strict").unwrap()).unwrap(); - assert!(url.query_params.use_ssl); - assert!(!url.query_params.ssl_opts.skip_domain_validation()); - assert!(!url.query_params.ssl_opts.accept_invalid_certs()); - } - - #[test] - fn should_parse_ipv6_host() { - let url = MysqlUrl::new(Url::parse("mysql://[2001:db8:1234::ffff]:5432/testdb").unwrap()).unwrap(); - assert_eq!("2001:db8:1234::ffff", url.host()); - } - - #[test] - fn should_allow_changing_of_cache_size() { - let url = MysqlUrl::new(Url::parse("mysql:///root:root@localhost:3307/foo?statement_cache_size=420").unwrap()) - .unwrap(); - assert_eq!(420, url.cache().capacity()); - } - - #[test] - fn should_have_default_cache_size() { - let url = MysqlUrl::new(Url::parse("mysql:///root:root@localhost:3307/foo").unwrap()).unwrap(); - assert_eq!(100, url.cache().capacity()); - } - - #[tokio::test] - async fn should_map_nonexisting_database_error() { - let mut url = Url::parse(&CONN_STR).unwrap(); - url.set_username("root").unwrap(); - url.set_path("/this_does_not_exist"); - - let url = url.as_str().to_string(); - let res = Quaint::new(&url).await; - - let err = res.unwrap_err(); - - match err.kind() { - ErrorKind::DatabaseDoesNotExist { db_name } => { - assert_eq!(Some("1049"), err.original_code()); - assert_eq!(Some("Unknown database \'this_does_not_exist\'"), err.original_message()); - assert_eq!(&Name::available("this_does_not_exist"), db_name) - } - e => panic!("Expected `DatabaseDoesNotExist`, got {:?}", e), - } - } - - #[tokio::test] - async fn should_map_wrong_credentials_error() { - let mut url = Url::parse(&CONN_STR).unwrap(); - url.set_username("WRONG").unwrap(); - - let res = Quaint::new(url.as_str()).await; - assert!(res.is_err()); - - let err = res.unwrap_err(); - assert!(matches!(err.kind(), ErrorKind::AuthenticationFailed { user } if user == &Name::available("WRONG"))); - } -} diff --git a/quaint/src/connector/mysql/url.rs b/quaint/src/connector/mysql/url.rs index c17b2224c0ef..f0756fa95833 100644 --- a/quaint/src/connector/mysql/url.rs +++ b/quaint/src/connector/mysql/url.rs @@ -316,3 +316,86 @@ pub(crate) struct MysqlUrlQueryParams { #[cfg(feature = "mysql-native")] pub(crate) ssl_opts: mysql_async::SslOpts, } + +#[cfg(test)] +mod tests { + use super::MysqlUrl; + use crate::tests::test_api::mysql::CONN_STR; + use crate::{error::*, single::Quaint}; + use url::Url; + + #[test] + fn should_parse_socket_url() { + let url = MysqlUrl::new(Url::parse("mysql://root@localhost/dbname?socket=(/tmp/mysql.sock)").unwrap()).unwrap(); + assert_eq!("dbname", url.dbname()); + assert_eq!(&Some(String::from("/tmp/mysql.sock")), url.socket()); + } + + #[test] + fn should_parse_prefer_socket() { + let url = + MysqlUrl::new(Url::parse("mysql://root:root@localhost:3307/testdb?prefer_socket=false").unwrap()).unwrap(); + assert!(!url.prefer_socket().unwrap()); + } + + #[test] + fn should_parse_sslaccept() { + let url = + MysqlUrl::new(Url::parse("mysql://root:root@localhost:3307/testdb?sslaccept=strict").unwrap()).unwrap(); + assert!(url.query_params.use_ssl); + assert!(!url.query_params.ssl_opts.skip_domain_validation()); + assert!(!url.query_params.ssl_opts.accept_invalid_certs()); + } + + #[test] + fn should_parse_ipv6_host() { + let url = MysqlUrl::new(Url::parse("mysql://[2001:db8:1234::ffff]:5432/testdb").unwrap()).unwrap(); + assert_eq!("2001:db8:1234::ffff", url.host()); + } + + #[test] + fn should_allow_changing_of_cache_size() { + let url = MysqlUrl::new(Url::parse("mysql:///root:root@localhost:3307/foo?statement_cache_size=420").unwrap()) + .unwrap(); + assert_eq!(420, url.cache().capacity()); + } + + #[test] + fn should_have_default_cache_size() { + let url = MysqlUrl::new(Url::parse("mysql:///root:root@localhost:3307/foo").unwrap()).unwrap(); + assert_eq!(100, url.cache().capacity()); + } + + #[tokio::test] + async fn should_map_nonexisting_database_error() { + let mut url = Url::parse(&CONN_STR).unwrap(); + url.set_username("root").unwrap(); + url.set_path("/this_does_not_exist"); + + let url = url.as_str().to_string(); + let res = Quaint::new(&url).await; + + let err = res.unwrap_err(); + + match err.kind() { + ErrorKind::DatabaseDoesNotExist { db_name } => { + assert_eq!(Some("1049"), err.original_code()); + assert_eq!(Some("Unknown database \'this_does_not_exist\'"), err.original_message()); + assert_eq!(&Name::available("this_does_not_exist"), db_name) + } + e => panic!("Expected `DatabaseDoesNotExist`, got {:?}", e), + } + } + + #[tokio::test] + async fn should_map_wrong_credentials_error() { + let mut url = Url::parse(&CONN_STR).unwrap(); + url.set_username("WRONG").unwrap(); + + let res = Quaint::new(url.as_str()).await; + assert!(res.is_err()); + + let err = res.unwrap_err(); + assert!(matches!(err.kind(), ErrorKind::AuthenticationFailed { user } if user == &Name::available("WRONG"))); + } +} diff --git a/quaint/src/connector/postgres/native/mod.rs b/quaint/src/connector/postgres/native/mod.rs index 5dbf67a91cdf..30f34e7002be 100644 --- a/quaint/src/connector/postgres/native/mod.rs +++ b/quaint/src/connector/postgres/native/mod.rs @@ -671,89 +671,11 @@ fn is_safe_identifier(ident: &str) -> bool { mod tests { use super::*; pub(crate) use crate::connector::postgres::url::PostgresFlavour; + use crate::connector::Queryable; use crate::tests::test_api::postgres::CONN_STR; use crate::tests::test_api::CRDB_CONN_STR; - use crate::{connector::Queryable, error::*, single::Quaint}; use url::Url; - #[test] - fn should_parse_socket_url() { - let url = PostgresUrl::new(Url::parse("postgresql:///dbname?host=/var/run/psql.sock").unwrap()).unwrap(); - assert_eq!("dbname", url.dbname()); - assert_eq!("/var/run/psql.sock", url.host()); - } - - #[test] - fn should_parse_escaped_url() { - let url = PostgresUrl::new(Url::parse("postgresql:///dbname?host=%2Fvar%2Frun%2Fpostgresql").unwrap()).unwrap(); - assert_eq!("dbname", url.dbname()); - assert_eq!("/var/run/postgresql", url.host()); - } - - #[test] - fn should_allow_changing_of_cache_size() { - let url = - PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?statement_cache_size=420").unwrap()).unwrap(); - assert_eq!(420, url.cache().capacity()); - } - - #[test] - fn should_have_default_cache_size() { - let url = PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo").unwrap()).unwrap(); - assert_eq!(100, url.cache().capacity()); - } - - #[test] - fn should_have_application_name() { - let url = - PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?application_name=test").unwrap()).unwrap(); - assert_eq!(Some("test"), url.application_name()); - } - - #[test] - fn should_have_channel_binding() { - let url = - PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?channel_binding=require").unwrap()).unwrap(); - assert_eq!(ChannelBinding::Require, url.channel_binding()); - } - - #[test] - fn should_have_default_channel_binding() { - let url = - PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?channel_binding=invalid").unwrap()).unwrap(); - assert_eq!(ChannelBinding::Prefer, url.channel_binding()); - - let url = PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo").unwrap()).unwrap(); - assert_eq!(ChannelBinding::Prefer, url.channel_binding()); - } - - #[test] - fn should_not_enable_caching_with_pgbouncer() { - let url = PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?pgbouncer=true").unwrap()).unwrap(); - assert_eq!(0, url.cache().capacity()); - } - - #[test] - fn should_parse_default_host() { - let url = PostgresUrl::new(Url::parse("postgresql:///dbname").unwrap()).unwrap(); - assert_eq!("dbname", url.dbname()); - assert_eq!("localhost", url.host()); - } - - #[test] - fn should_parse_ipv6_host() { - let url = PostgresUrl::new(Url::parse("postgresql://[2001:db8:1234::ffff]:5432/dbname").unwrap()).unwrap(); - assert_eq!("2001:db8:1234::ffff", url.host()); - } - - #[test] - fn should_handle_options_field() { - let url = PostgresUrl::new(Url::parse("postgresql:///localhost:5432?options=--cluster%3Dmy_cluster").unwrap()) - .unwrap(); - - assert_eq!("--cluster=my_cluster", url.options().unwrap()); - } - #[tokio::test] async fn test_custom_search_path_pg() { async fn test_path(schema_name: &str) -> Option { @@ -1010,82 +932,6 @@ mod tests { } } - #[tokio::test] - async fn should_map_nonexisting_database_error() { - let mut url = Url::parse(&CONN_STR).unwrap(); - url.set_path("/this_does_not_exist"); - - let res = Quaint::new(url.as_str()).await; - - assert!(res.is_err()); - - match res { - Ok(_) => unreachable!(), - Err(e) => match e.kind() { - ErrorKind::DatabaseDoesNotExist { db_name } => { - assert_eq!(Some("3D000"), e.original_code()); - assert_eq!( - Some("database \"this_does_not_exist\" does not exist"), - e.original_message() - ); - assert_eq!(&Name::available("this_does_not_exist"), db_name) - } - kind => panic!("Expected `DatabaseDoesNotExist`, got {:?}", kind), - }, - } - } - - #[tokio::test] - async fn should_map_wrong_credentials_error() { - let mut url = Url::parse(&CONN_STR).unwrap(); - url.set_username("WRONG").unwrap(); - - let res = Quaint::new(url.as_str()).await; - assert!(res.is_err()); - - let err = res.unwrap_err(); - assert!(matches!(err.kind(), ErrorKind::AuthenticationFailed { user } if user == &Name::available("WRONG"))); - } - - #[tokio::test] - async fn should_map_tls_errors() { - let mut url = Url::parse(&CONN_STR).expect("parsing url"); - url.set_query(Some("sslmode=require&sslaccept=strict")); - - let res = Quaint::new(url.as_str()).await; - - assert!(res.is_err()); - - match res { - Ok(_) => unreachable!(), - Err(e) => match e.kind() { - ErrorKind::TlsError { .. } => (), - other => panic!("{:#?}", other), - }, - } - } - - #[tokio::test] - async fn should_map_incorrect_parameters_error() { - let url = Url::parse(&CONN_STR).unwrap(); - let conn = Quaint::new(url.as_str()).await.unwrap(); - - let res = conn.query_raw("SELECT $1", &[Value::int32(1), Value::int32(2)]).await; - - assert!(res.is_err()); - - match res { - Ok(_) => unreachable!(), - Err(e) => match e.kind() { - ErrorKind::IncorrectNumberOfParameters { expected, actual } => { - assert_eq!(1, *expected); - assert_eq!(2, *actual); - } - other => panic!("{:#?}", other), - }, - } - } - #[test] fn test_safe_ident() { // Safe @@ -1123,63 +969,4 @@ mod tests { assert!(!is_safe_identifier(ident)); } } - - #[test] - fn search_path_pgbouncer_should_be_set_with_query() { - let mut url = Url::parse(&CONN_STR).unwrap(); - url.query_pairs_mut().append_pair("schema", "hello"); - url.query_pairs_mut().append_pair("pgbouncer", "true"); - - let mut pg_url = PostgresUrl::new(url).unwrap(); - pg_url.set_flavour(PostgresFlavour::Postgres); - - let config = pg_url.to_config(); - - // PGBouncer does not support the `search_path` connection parameter. - // When `pgbouncer=true`, config.search_path should be None, - // And the `search_path` should be set via a db query after connection. - assert_eq!(config.get_search_path(), None); - } - - #[test] - fn search_path_pg_should_be_set_with_param() { - let mut url = Url::parse(&CONN_STR).unwrap(); - url.query_pairs_mut().append_pair("schema", "hello"); - - let mut pg_url = PostgresUrl::new(url).unwrap(); - pg_url.set_flavour(PostgresFlavour::Postgres); - - let config = pg_url.to_config(); - - // Postgres supports setting the search_path via a connection parameter. - assert_eq!(config.get_search_path(), Some(&"\"hello\"".to_owned())); - } - - #[test] - fn search_path_crdb_safe_ident_should_be_set_with_param() { - let mut url = Url::parse(&CONN_STR).unwrap(); - url.query_pairs_mut().append_pair("schema", "hello"); - - let mut pg_url = PostgresUrl::new(url).unwrap(); - pg_url.set_flavour(PostgresFlavour::Cockroach); - - let config = pg_url.to_config(); - - // CRDB supports setting the search_path via a connection parameter if the identifier is safe. - assert_eq!(config.get_search_path(), Some(&"hello".to_owned())); - } - - #[test] - fn search_path_crdb_unsafe_ident_should_be_set_with_query() { - let mut url = Url::parse(&CONN_STR).unwrap(); - url.query_pairs_mut().append_pair("schema", "HeLLo"); - - let mut pg_url = PostgresUrl::new(url).unwrap(); - pg_url.set_flavour(PostgresFlavour::Cockroach); - - let config = pg_url.to_config(); - - // CRDB does NOT support setting the search_path via a connection parameter if the identifier is unsafe. - assert_eq!(config.get_search_path(), None); - } } diff --git a/quaint/src/connector/postgres/url.rs b/quaint/src/connector/postgres/url.rs index 7b9b3aafabb4..f0b60d88a848 100644 --- a/quaint/src/connector/postgres/url.rs +++ b/quaint/src/connector/postgres/url.rs @@ -470,3 +470,226 @@ impl Display for SetSearchPath<'_> { Ok(()) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::ast::Value; + pub(crate) use crate::connector::postgres::url::PostgresFlavour; + use crate::tests::test_api::postgres::CONN_STR; + use crate::{connector::Queryable, error::*, single::Quaint}; + use url::Url; + + #[test] + fn should_parse_socket_url() { + let url = PostgresUrl::new(Url::parse("postgresql:///dbname?host=/var/run/psql.sock").unwrap()).unwrap(); + assert_eq!("dbname", url.dbname()); + assert_eq!("/var/run/psql.sock", url.host()); + } + + #[test] + fn should_parse_escaped_url() { + let url = PostgresUrl::new(Url::parse("postgresql:///dbname?host=%2Fvar%2Frun%2Fpostgresql").unwrap()).unwrap(); + assert_eq!("dbname", url.dbname()); + assert_eq!("/var/run/postgresql", url.host()); + } + + #[test] + fn should_allow_changing_of_cache_size() { + let url = + PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?statement_cache_size=420").unwrap()).unwrap(); + assert_eq!(420, url.cache().capacity()); + } + + #[test] + fn should_have_default_cache_size() { + let url = PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo").unwrap()).unwrap(); + assert_eq!(100, url.cache().capacity()); + } + + #[test] + fn should_have_application_name() { + let url = + PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?application_name=test").unwrap()).unwrap(); + assert_eq!(Some("test"), url.application_name()); + } + + #[test] + fn should_have_channel_binding() { + let url = + PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?channel_binding=require").unwrap()).unwrap(); + assert_eq!(ChannelBinding::Require, url.channel_binding()); + } + + #[test] + fn should_have_default_channel_binding() { + let url = + PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?channel_binding=invalid").unwrap()).unwrap(); + assert_eq!(ChannelBinding::Prefer, url.channel_binding()); + + let url = PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo").unwrap()).unwrap(); + assert_eq!(ChannelBinding::Prefer, url.channel_binding()); + } + + #[test] + fn should_not_enable_caching_with_pgbouncer() { + let url = PostgresUrl::new(Url::parse("postgresql:///localhost:5432/foo?pgbouncer=true").unwrap()).unwrap(); + assert_eq!(0, url.cache().capacity()); + } + + #[test] + fn should_parse_default_host() { + let url = PostgresUrl::new(Url::parse("postgresql:///dbname").unwrap()).unwrap(); + assert_eq!("dbname", url.dbname()); + assert_eq!("localhost", url.host()); + } + + #[test] + fn should_parse_ipv6_host() { + let url = PostgresUrl::new(Url::parse("postgresql://[2001:db8:1234::ffff]:5432/dbname").unwrap()).unwrap(); + assert_eq!("2001:db8:1234::ffff", url.host()); + } + + #[test] + fn should_handle_options_field() { + let url = PostgresUrl::new(Url::parse("postgresql:///localhost:5432?options=--cluster%3Dmy_cluster").unwrap()) + .unwrap(); + + assert_eq!("--cluster=my_cluster", url.options().unwrap()); + } + + #[tokio::test] + async fn should_map_nonexisting_database_error() { + let mut url = Url::parse(&CONN_STR).unwrap(); + url.set_path("/this_does_not_exist"); + + let res = Quaint::new(url.as_str()).await; + + assert!(res.is_err()); + + match res { + Ok(_) => unreachable!(), + Err(e) => match e.kind() { + ErrorKind::DatabaseDoesNotExist { db_name } => { + assert_eq!(Some("3D000"), e.original_code()); + assert_eq!( + Some("database \"this_does_not_exist\" does not exist"), + e.original_message() + ); + assert_eq!(&Name::available("this_does_not_exist"), db_name) + } + kind => panic!("Expected `DatabaseDoesNotExist`, got {:?}", kind), + }, + } + } + + #[tokio::test] + async fn should_map_wrong_credentials_error() { + let mut url = Url::parse(&CONN_STR).unwrap(); + url.set_username("WRONG").unwrap(); + + let res = Quaint::new(url.as_str()).await; + assert!(res.is_err()); + + let err = res.unwrap_err(); + assert!(matches!(err.kind(), ErrorKind::AuthenticationFailed { user } if user == &Name::available("WRONG"))); + } + + #[tokio::test] + async fn should_map_tls_errors() { + let mut url = Url::parse(&CONN_STR).expect("parsing url"); + url.set_query(Some("sslmode=require&sslaccept=strict")); + + let res = Quaint::new(url.as_str()).await; + + assert!(res.is_err()); + + match res { + Ok(_) => unreachable!(), + Err(e) => match e.kind() { + ErrorKind::TlsError { .. } => (), + other => panic!("{:#?}", other), + }, + } + } + + #[tokio::test] + async fn should_map_incorrect_parameters_error() { + let url = Url::parse(&CONN_STR).unwrap(); + let conn = Quaint::new(url.as_str()).await.unwrap(); + + let res = conn.query_raw("SELECT $1", &[Value::int32(1), Value::int32(2)]).await; + + assert!(res.is_err()); + + match res { + Ok(_) => unreachable!(), + Err(e) => match e.kind() { + ErrorKind::IncorrectNumberOfParameters { expected, actual } => { + assert_eq!(1, *expected); + assert_eq!(2, *actual); + } + other => panic!("{:#?}", other), + }, + } + } + + #[test] + fn search_path_pgbouncer_should_be_set_with_query() { + let mut url = Url::parse(&CONN_STR).unwrap(); + url.query_pairs_mut().append_pair("schema", "hello"); + url.query_pairs_mut().append_pair("pgbouncer", "true"); + + let mut pg_url = PostgresUrl::new(url).unwrap(); + pg_url.set_flavour(PostgresFlavour::Postgres); + + let config = pg_url.to_config(); + + // PGBouncer does not support the `search_path` connection parameter. + // When `pgbouncer=true`, config.search_path should be None, + // And the `search_path` should be set via a db query after connection. + assert_eq!(config.get_search_path(), None); + } + + #[test] + fn search_path_pg_should_be_set_with_param() { + let mut url = Url::parse(&CONN_STR).unwrap(); + url.query_pairs_mut().append_pair("schema", "hello"); + + let mut pg_url = PostgresUrl::new(url).unwrap(); + pg_url.set_flavour(PostgresFlavour::Postgres); + + let config = pg_url.to_config(); + + // Postgres supports setting the search_path via a connection parameter. + assert_eq!(config.get_search_path(), Some(&"\"hello\"".to_owned())); + } + + #[test] + fn search_path_crdb_safe_ident_should_be_set_with_param() { + let mut url = Url::parse(&CONN_STR).unwrap(); + url.query_pairs_mut().append_pair("schema", "hello"); + + let mut pg_url = PostgresUrl::new(url).unwrap(); + pg_url.set_flavour(PostgresFlavour::Cockroach); + + let config = pg_url.to_config(); + + // CRDB supports setting the search_path via a connection parameter if the identifier is safe. + assert_eq!(config.get_search_path(), Some(&"hello".to_owned())); + } + + #[test] + fn search_path_crdb_unsafe_ident_should_be_set_with_query() { + let mut url = Url::parse(&CONN_STR).unwrap(); + url.query_pairs_mut().append_pair("schema", "HeLLo"); + + let mut pg_url = PostgresUrl::new(url).unwrap(); + pg_url.set_flavour(PostgresFlavour::Cockroach); + + let config = pg_url.to_config(); + + // CRDB does NOT support setting the search_path via a connection parameter if the identifier is unsafe. + assert_eq!(config.get_search_path(), None); + } +} diff --git a/quaint/src/connector/sqlite/native/mod.rs b/quaint/src/connector/sqlite/native/mod.rs index 4b686f5968d6..3bf0c46a7db5 100644 --- a/quaint/src/connector/sqlite/native/mod.rs +++ b/quaint/src/connector/sqlite/native/mod.rs @@ -165,27 +165,6 @@ mod tests { error::{ErrorKind, Name}, }; - #[test] - fn sqlite_params_from_str_should_resolve_path_correctly_with_file_scheme() { - let path = "file:dev.db"; - let params = SqliteParams::try_from(path).unwrap(); - assert_eq!(params.file_path, "dev.db"); - } - - #[test] - fn sqlite_params_from_str_should_resolve_path_correctly_with_sqlite_scheme() { - let path = "sqlite:dev.db"; - let params = SqliteParams::try_from(path).unwrap(); - assert_eq!(params.file_path, "dev.db"); - } - - #[test] - fn sqlite_params_from_str_should_resolve_path_correctly_with_no_scheme() { - let path = "dev.db"; - let params = SqliteParams::try_from(path).unwrap(); - assert_eq!(params.file_path, "dev.db"); - } - #[tokio::test] async fn unknown_table_should_give_a_good_error() { let conn = Sqlite::try_from("file:db/test.db").unwrap(); diff --git a/quaint/src/connector/sqlite/params.rs b/quaint/src/connector/sqlite/params.rs index 46fb5c08f669..f024aa97a694 100644 --- a/quaint/src/connector/sqlite/params.rs +++ b/quaint/src/connector/sqlite/params.rs @@ -103,3 +103,29 @@ impl TryFrom<&str> for SqliteParams { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn sqlite_params_from_str_should_resolve_path_correctly_with_file_scheme() { + let path = "file:dev.db"; + let params = SqliteParams::try_from(path).unwrap(); + assert_eq!(params.file_path, "dev.db"); + } + + #[test] + fn sqlite_params_from_str_should_resolve_path_correctly_with_sqlite_scheme() { + let path = "sqlite:dev.db"; + let params = SqliteParams::try_from(path).unwrap(); + assert_eq!(params.file_path, "dev.db"); + } + + #[test] + fn sqlite_params_from_str_should_resolve_path_correctly_with_no_scheme() { + let path = "dev.db"; + let params = SqliteParams::try_from(path).unwrap(); + assert_eq!(params.file_path, "dev.db"); + } +} From bacb635367bb994939c9cdcf530033d334a3224b Mon Sep 17 00:00:00 2001 From: jkomyno Date: Wed, 15 Nov 2023 17:19:27 +0100 Subject: [PATCH 7/8] chore: add comment on MysqlAsyncError --- quaint/src/connector/mysql/error.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/quaint/src/connector/mysql/error.rs b/quaint/src/connector/mysql/error.rs index 615f0c69dda4..7b4813bf0223 100644 --- a/quaint/src/connector/mysql/error.rs +++ b/quaint/src/connector/mysql/error.rs @@ -1,6 +1,8 @@ use crate::error::{DatabaseConstraint, Error, ErrorKind}; use thiserror::Error; +// This is a partial copy of the `mysql_async::Error` using only the enum variant used by Prisma. +// This avoids pulling in `mysql_async`, which would break Wasm compilation. #[derive(Debug, Error)] enum MysqlAsyncError { #[error("Server error: `{}'", _0)] From 263bab0c84a396cf5867dd65911c2af79cad7824 Mon Sep 17 00:00:00 2001 From: jkomyno Date: Wed, 15 Nov 2023 17:22:52 +0100 Subject: [PATCH 8/8] chore: add comment on ffi.rs for sqlite --- quaint/src/connector/sqlite/ffi.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quaint/src/connector/sqlite/ffi.rs b/quaint/src/connector/sqlite/ffi.rs index bddfd4354237..c510a459be81 100644 --- a/quaint/src/connector/sqlite/ffi.rs +++ b/quaint/src/connector/sqlite/ffi.rs @@ -1,4 +1,5 @@ -//! This is a partial copy of `rusqlite::ffi::*`. +//! Here, we export only the constants we need to avoid pulling in `rusqlite::ffi::*`, in the sibling `error.rs` file, +//! which would break Wasm compilation. pub const SQLITE_BUSY: i32 = 5; pub const SQLITE_CONSTRAINT_FOREIGNKEY: i32 = 787; pub const SQLITE_CONSTRAINT_NOTNULL: i32 = 1299;