fix: found a few more changes needed in internal core usage in macros

This commit is contained in:
Ryan Leckey 2020-05-30 18:11:05 -07:00
parent 9b299d9f09
commit d4d994bae4
No known key found for this signature in database
GPG Key ID: BBDFC5595030E7D3
2 changed files with 7 additions and 4 deletions

View File

@ -73,7 +73,7 @@ macro_rules! impl_database_ext {
} }
} }
fn get_feature_gate($name: &Self::TypeInfo) -> Option<&'static str> { fn get_feature_gate($ty_info: &Self::TypeInfo) -> Option<&'static str> {
$get_gate $get_gate
} }
} }

View File

@ -62,12 +62,15 @@ pub fn expand_input(input: QueryMacroInput) -> crate::Result<TokenStream> {
#[allow(unused_variables)] #[allow(unused_variables)]
fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenStream> { fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenStream> {
// FIXME: Introduce [sqlx::any::AnyConnection] and [sqlx::any::AnyDatabase] to support
// runtime determinism here
let db_url = Url::parse(db_url)?; let db_url = Url::parse(db_url)?;
match db_url.scheme() { match db_url.scheme() {
#[cfg(feature = "postgres")] #[cfg(feature = "postgres")]
"postgres" | "postgresql" => { "postgres" | "postgresql" => {
let data = block_on(async { let data = block_on(async {
let mut conn = sqlx_core::postgres::PgConnection::connect(db_url).await?; let mut conn = sqlx_core::postgres::PgConnection::connect(db_url.as_str()).await?;
QueryData::from_db(&mut conn, &input.src).await QueryData::from_db(&mut conn, &input.src).await
})?; })?;
@ -78,7 +81,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
#[cfg(feature = "mysql")] #[cfg(feature = "mysql")]
"mysql" | "mariadb" => { "mysql" | "mariadb" => {
let data = block_on(async { let data = block_on(async {
let mut conn = sqlx_core::mysql::MySqlConnection::connect(db_url).await?; let mut conn = sqlx_core::mysql::MySqlConnection::connect(db_url.as_str()).await?;
QueryData::from_db(&mut conn, &input.src).await QueryData::from_db(&mut conn, &input.src).await
})?; })?;
@ -89,7 +92,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
#[cfg(feature = "sqlite")] #[cfg(feature = "sqlite")]
"sqlite" => { "sqlite" => {
let data = block_on(async { let data = block_on(async {
let mut conn = sqlx_core::sqlite::SqliteConnection::connect(db_url).await?; let mut conn = sqlx_core::sqlite::SqliteConnection::connect(db_url.as_str()).await?;
QueryData::from_db(&mut conn, &input.src).await QueryData::from_db(&mut conn, &input.src).await
})?; })?;