From 35b101e49f7a16bc0e2e4e2d4c7ef3938ac9f473 Mon Sep 17 00:00:00 2001 From: Alberto Schiabel Date: Wed, 13 Dec 2023 09:15:08 +0100 Subject: [PATCH] feat(driver-adapters): remove fallback for "provider"/"flavour" (#4554) * feat(driver-adapters): remove fallback for "provider"/"flavour" * chore: fix clippy --- query-engine/driver-adapters/src/lib.rs | 4 ++-- query-engine/driver-adapters/src/proxy.rs | 14 +++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/query-engine/driver-adapters/src/lib.rs b/query-engine/driver-adapters/src/lib.rs index 196b3e3c3f77..b5b1cf666e06 100644 --- a/query-engine/driver-adapters/src/lib.rs +++ b/query-engine/driver-adapters/src/lib.rs @@ -90,7 +90,7 @@ mod arch { } } - pub(crate) fn has_named_property(object: &super::wasm::JsObjectExtern, name: &str) -> JsResult { + fn has_named_property(object: &super::wasm::JsObjectExtern, name: &str) -> JsResult { js_sys::Reflect::has(object, &JsString::from_str(name).unwrap().into()) } @@ -130,7 +130,7 @@ mod arch { } } - pub(crate) fn has_named_property(object: &::napi::JsObject, name: &str) -> JsResult { + fn has_named_property(object: &::napi::JsObject, name: &str) -> JsResult { object.has_named_property(name) } diff --git a/query-engine/driver-adapters/src/proxy.rs b/query-engine/driver-adapters/src/proxy.rs index ae652f1ef699..1c16663903ca 100644 --- a/query-engine/driver-adapters/src/proxy.rs +++ b/query-engine/driver-adapters/src/proxy.rs @@ -2,8 +2,8 @@ use crate::send_future::UnsafeFuture; use crate::types::JsConnectionInfo; pub use crate::types::{ColumnType, JSResultSet, Query, TransactionOptions}; use crate::{ - from_js_value, get_named_property, get_optional_named_property, has_named_property, to_rust_str, AdapterMethod, - JsObject, JsResult, JsString, JsTransaction, + from_js_value, get_named_property, get_optional_named_property, to_rust_str, AdapterMethod, JsObject, JsResult, + JsString, JsTransaction, }; use futures::Future; @@ -56,15 +56,7 @@ pub(crate) struct TransactionProxy { impl CommonProxy { pub fn new(object: &JsObject) -> JsResult { - // Background info: - // - the provider was previously called "flavour", so we provide a temporary fallback for third-party providers - // to give them time to adapt - // - reading a named property that does not exist yields a panic, despite the `Result<_, _>` return type - let provider: JsString = if has_named_property(object, "provider")? { - get_named_property(object, "provider")? - } else { - get_named_property(object, "flavour")? - }; + let provider: JsString = get_named_property(object, "provider")?; Ok(Self { query_raw: get_named_property(object, "queryRaw")?,