yutannihilation / savvy

A simple R extension interface using Rust
https://yutannihilation.github.io/savvy/guide/
MIT License
70 stars 4 forks source link

Optional Struct argument is not allowed #255

Closed eitsupi closed 5 months ago

eitsupi commented 5 months ago

From eitsupi/r-glaredb#11

If a function having optional struct argument is created as shown below, it seems to cause an error if NULL is passed on the R side.

pub fn sql(query: &str, connection: Option<RGlareDbConnection>) -> savvy::Result<RGlareDbExecutionOutput> {
    if let Some(connection) = connection {
        connection.sql(query)
    } else {
        RGlareDbConnection::default_in_memory()?.sql(query)
    }
}
> sql("select 'hello'", NULL)
Error: Expected RGlareDbConnection, got NULL
yutannihilation commented 5 months ago

Oh, thanks for catching!

yutannihilation commented 5 months ago

Should be fixed now. Please update the dev version of savvy-cli and run savvy-cli update.

eitsupi commented 5 months ago

Wow, what a very quick update! Thanks.