Skip to content

Commit

Permalink
chore(driver-adapters): fixed panic on CommonProxy's fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Dec 1, 2023
1 parent 6add207 commit 89eaa48
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion query-engine/driver-adapters/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,15 @@ impl TryFrom<JSResultSet> for QuaintResultSet {

impl CommonProxy {
pub fn new(object: &JsObject) -> napi::Result<Self> {
let provider: JsString = object.get_named_property("provider").or_else(|_| object.get_named_property("flavour"))?;
// Background infos:
// - 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 object.has_named_property("provider")? {
object.get_named_property("provider")?
} else {
object.get_named_property("flavour")?
};

Ok(Self {
query_raw: object.get_named_property("queryRaw")?,
Expand Down

0 comments on commit 89eaa48

Please sign in to comment.