Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(query-engine-wasm): quick and dirty SQLite-only Wasm QE #4606

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/user-facing-errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ backtrace = "0.3.40"
tracing = "0.1"
indoc.workspace = true
itertools.workspace = true
quaint = { path = "../../quaint", optional = true }
quaint = { path = "../../quaint", optional = true, default-features = false, features = ["sqlite"] }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion query-engine/connectors/sql-query-connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ hex = "0.4"
quaint.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
quaint = { path = "../../../quaint" }
quaint = { path = "../../../quaint", default-features = false, features = ["sqlite"] }

[dependencies.connector-interface]
package = "query-connector"
Expand Down
13 changes: 7 additions & 6 deletions query-engine/driver-adapters/src/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ impl JsBaseQueryable {
/// visit a quaint query AST according to the provider of the JS connector
fn visit_quaint_query<'a>(&self, q: QuaintQuery<'a>) -> quaint::Result<(String, Vec<quaint::Value<'a>>)> {
match self.provider {
AdapterFlavour::Mysql => visitor::Mysql::build(q),
AdapterFlavour::Postgres => visitor::Postgres::build(q),
AdapterFlavour::Sqlite => visitor::Sqlite::build(q),
// AdapterFlavour::Mysql => visitor::Mysql::build(q),
// AdapterFlavour::Postgres => visitor::Postgres::build(q),
}
}

async fn build_query(&self, sql: &str, values: &[quaint::Value<'_>]) -> quaint::Result<Query> {
let sql: String = sql.to_string();

let converter = match self.provider {
AdapterFlavour::Postgres => conversion::postgres::value_to_js_arg,
AdapterFlavour::Sqlite => conversion::sqlite::value_to_js_arg,
AdapterFlavour::Mysql => conversion::mysql::value_to_js_arg,
// AdapterFlavour::Postgres => conversion::postgres::value_to_js_arg,
// AdapterFlavour::Mysql => conversion::mysql::value_to_js_arg,
};

let args = values
Expand Down Expand Up @@ -142,8 +142,9 @@ impl QuaintQueryable for JsBaseQueryable {

fn requires_isolation_first(&self) -> bool {
match self.provider {
AdapterFlavour::Mysql => true,
AdapterFlavour::Postgres | AdapterFlavour::Sqlite => false,
AdapterFlavour::Sqlite => false,
// AdapterFlavour::Mysql => true,
// AdapterFlavour::Postgres => false,
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions query-engine/driver-adapters/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ use serde_repr::{Deserialize_repr, Serialize_repr};
#[cfg_attr(target_arch = "wasm32", tsify(into_wasm_abi, from_wasm_abi))]
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum AdapterFlavour {
Mysql,
Postgres,
Sqlite,
// Mysql,
// Postgres,
}

impl FromStr for AdapterFlavour {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"postgres" => Ok(Self::Postgres),
"mysql" => Ok(Self::Mysql),
"sqlite" => Ok(Self::Sqlite),
// "postgres" => Ok(Self::Postgres),
// "mysql" => Ok(Self::Mysql),
_ => Err(format!("Unsupported adapter flavour: {:?}", s)),
}
}
Expand All @@ -38,9 +38,9 @@ impl FromStr for AdapterFlavour {
impl From<AdapterFlavour> for SqlFamily {
fn from(value: AdapterFlavour) -> Self {
match value {
AdapterFlavour::Mysql => SqlFamily::Mysql,
AdapterFlavour::Postgres => SqlFamily::Postgres,
AdapterFlavour::Sqlite => SqlFamily::Sqlite,
// AdapterFlavour::Mysql => SqlFamily::Mysql,
// AdapterFlavour::Postgres => SqlFamily::Postgres,
}
}
}
Expand Down Expand Up @@ -69,9 +69,9 @@ impl JsConnectionInfo {

fn default_schema_name(&self, provider: &AdapterFlavour) -> &str {
match provider {
AdapterFlavour::Mysql => quaint::connector::DEFAULT_MYSQL_DB,
AdapterFlavour::Postgres => quaint::connector::DEFAULT_POSTGRES_SCHEMA,
AdapterFlavour::Sqlite => quaint::connector::DEFAULT_SQLITE_DATABASE,
// AdapterFlavour::Mysql => quaint::connector::DEFAULT_MYSQL_DB,
// AdapterFlavour::Postgres => quaint::connector::DEFAULT_POSTGRES_SCHEMA,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion query-engine/query-engine-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async-trait = "0.1"
user-facing-errors = { path = "../../libs/user-facing-errors" }
psl.workspace = true
query-structure = { path = "../query-structure" }
quaint = { path = "../../quaint" }
quaint = { path = "../../quaint", default-features = false, features = ["sqlite"] }
sql-connector = { path = "../connectors/sql-query-connector", package = "sql-query-connector" }
request-handlers = { path = "../request-handlers", default-features = false, features = [
"sql",
Expand Down
2 changes: 1 addition & 1 deletion query-engine/request-handlers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
query-structure = { path = "../query-structure" }
query-core = { path = "../core" }
user-facing-errors = { path = "../../libs/user-facing-errors" }
quaint = { path = "../../quaint" }
quaint = { path = "../../quaint", default-features = false, features = ["sqlite"] }
psl.workspace = true
dmmf_crate = { path = "../dmmf", package = "dmmf" }
itertools.workspace = true
Expand Down
Loading