-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sql-schema-connector): wasm-compatible
sql-schema-connector
(#…
…5126) * feat(sql-schema-connector): enable wasm compilation with "--features sqlite" * feat(sql-schema-connector): enable wasm compilation with "--features postgresql" and "--features cockroachdb" * feat(sql-schema-connector): get rid of sql-schema-connector-wasm * fix(sql-schema-connector): remove typo, fix migration tests * feat(sql-schema-connector): expose external constructors for postgres, sqlite * feat(sql-schema-connector): enable wasm compilation with "--features mysql" * chore: remove typo * feat(sql-schema-connector): enable wasm compilation with "--features mssql"; update mssql's quaint::visitor::Visitor * chore(schema-engine-wasm): typo --------- Co-authored-by: jkomyno <[email protected]>
- Loading branch information
Showing
42 changed files
with
854 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 11 additions & 3 deletions
14
schema-engine/connectors/sql-schema-connector/src/flavour/mssql.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...connector/src/flavour/mssql/connection.rs → ...connector/src/flavour/mssql/native/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...-connector/src/flavour/mssql/shadow_db.rs → ...tor/src/flavour/mssql/native/shadow_db.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
schema-engine/connectors/sql-schema-connector/src/flavour/mssql/wasm/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//! All the quaint-wrangling for the mssql connector should happen here. | ||
pub(super) mod shadow_db; | ||
|
||
use enumflags2::BitFlags; | ||
use quaint::connector::{ColumnType, DescribedColumn, DescribedParameter, GetRow, MssqlUrl, ToColumnNames}; | ||
use schema_connector::{BoxFuture, ConnectorError, ConnectorResult, Namespaces}; | ||
use sql_schema_describer::{mssql as describer, DescriberErrorKind, SqlSchema}; | ||
use user_facing_errors::schema_engine::ApplyMigrationError; | ||
|
||
// TODO: use ExternalConnector here. | ||
pub(super) struct Connection(); | ||
|
||
impl Connection { | ||
pub(super) async fn new(connection_str: &str) -> ConnectorResult<Self> { | ||
panic!("[sql-schema-connector::flavour::mssql::wasm] Not implemented"); | ||
} | ||
|
||
#[tracing::instrument(skip(self, params))] | ||
pub(super) async fn describe_schema( | ||
&mut self, | ||
params: &super::Params, | ||
namespaces: Option<Namespaces>, | ||
) -> ConnectorResult<SqlSchema> { | ||
panic!("[sql-schema-connector::flavour::mssql::wasm] Not implemented"); | ||
} | ||
|
||
pub(super) async fn raw_cmd(&mut self, sql: &str, params: &super::Params) -> ConnectorResult<()> { | ||
tracing::debug!(query_type = "raw_cmd", sql); | ||
panic!("[sql-schema-connector::flavour::mssql::wasm] Not implemented"); | ||
} | ||
|
||
pub(super) async fn version(&mut self, params: &super::Params) -> ConnectorResult<Option<String>> { | ||
tracing::debug!(query_type = "version"); | ||
panic!("[sql-schema-connector::flavour::mssql::wasm] Not implemented"); | ||
} | ||
|
||
pub(super) async fn query( | ||
&mut self, | ||
query: quaint::ast::Query<'_>, | ||
conn_params: &super::Params, | ||
) -> ConnectorResult<quaint::prelude::ResultSet> { | ||
use quaint::visitor::Visitor; | ||
let (sql, params) = quaint::visitor::Mssql::build(query).unwrap(); | ||
self.query_raw(&sql, ¶ms, conn_params).await | ||
} | ||
|
||
pub(super) async fn query_raw( | ||
&mut self, | ||
sql: &str, | ||
params: &[quaint::prelude::Value<'_>], | ||
conn_params: &super::Params, | ||
) -> ConnectorResult<quaint::prelude::ResultSet> { | ||
tracing::debug!(query_type = "query_raw", sql); | ||
panic!("[sql-schema-connector::flavour::mssql::wasm] Not implemented"); | ||
} | ||
} | ||
|
||
pub(super) async fn generic_apply_migration_script( | ||
migration_name: &str, | ||
script: &str, | ||
conn: &mut Connection, | ||
) -> ConnectorResult<()> { | ||
tracing::debug!(query_type = "raw_cmd", script); | ||
panic!("[sql-schema-connector::flavour::mssql::wasm] Not implemented"); | ||
} |
12 changes: 12 additions & 0 deletions
12
schema-engine/connectors/sql-schema-connector/src/flavour/mssql/wasm/shadow_db.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use crate::flavour::{MssqlFlavour, SqlFlavour}; | ||
use schema_connector::Namespaces; | ||
use schema_connector::{migrations_directory::MigrationDirectory, ConnectorResult}; | ||
use sql_schema_describer::SqlSchema; | ||
|
||
pub async fn sql_schema_from_migrations_history( | ||
migrations: &[MigrationDirectory], | ||
mut shadow_db: MssqlFlavour, | ||
namespaces: Option<Namespaces>, | ||
) -> ConnectorResult<SqlSchema> { | ||
panic!("[sql-schema-connector::flavour::mssql::wasm] Not implemented"); | ||
} |
14 changes: 11 additions & 3 deletions
14
schema-engine/connectors/sql-schema-connector/src/flavour/mysql.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...connector/src/flavour/mysql/connection.rs → ...connector/src/flavour/mysql/native/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.