- 
                Notifications
    
You must be signed in to change notification settings  - Fork 177
 
Closed
Labels
featureUsed for auto generate changelogUsed for auto generate changeloggood first issueGood for newcomersGood for newcomers
Description
As far as I can tell named parameters are not supported, are there any plans to do so? I'm trying to port some duckdb Python code to duckdb-rs but the public API of the code allows named parameters.
Looking at the C API, it seems like this could be supported by iterating through the parameters and calling duckdb_parameter_name on each, then looking up the name in a passed-in HashMap-like trait.
Note that I can almost do this myself, except that duckdb_parameter_name isn't exposed anywhere on Statement.  If it were I could do something like:
#[tokio::test]
    async fn test_bind_params() -> Result<(), Error> {
        let conn = duckdb::Connection::open_in_memory().expect("Could not open DB");
        let sql = r#"SELECT $foo > $bar"#;
        let mut named_params: HashMap<String, &dyn duckdb::ToSql> = HashMap::new();
        named_params.insert("foo".to_string(), &42);
        named_params.insert("bar".to_string(), &23);
        let mut stmt = conn.prepare(&sql)?;
        // TODO: build params by calling stmt.get_param_name(index) to find each name to lookup
        let params: Vec<&dyn ToSql> = vec![&42, &23];
        let result: bool = stmt.query_one(params.as_slice(), |row| {row.get(0)})?;
        assert_eq!(result, true);
        Ok(())
    }doxxx93
Metadata
Metadata
Assignees
Labels
featureUsed for auto generate changelogUsed for auto generate changeloggood first issueGood for newcomersGood for newcomers