Giorgi / DuckDB.NET

Bindings and ADO.NET Provider for DuckDB
https://duckdb.net
MIT License
343 stars 62 forks source link

DbParameter Support #69

Closed bnuzhouwei closed 9 months ago

bnuzhouwei commented 1 year ago

ADO default use @param as paremnt, but duckdb use ?, can fill the gap with specified name of parameters?

Giorgi commented 1 year ago

@bnuzhouwei DuckDB itself doesn't support named parameters

bnuzhouwei commented 1 year ago

Could implement the parameters in the driver just like SQLite

Giorgi commented 1 year ago

SQLite has sqlite3_bind_parameter_index api that returns index of the parameter given it's name. There is no such API in DuckDB.

bnuzhouwei commented 1 year ago

The same issue exists in ClickHouse driver of ADO, while the jdbc driver works well among different databases. It's a pitty for .NET Ecosystem that hard to get consistent api of ADO among different databases.

Giorgi commented 1 year ago

You can open an issue for named parameters at the DuckDB repository If it gets added, I'll add support for it too.

bnuzhouwei commented 1 year ago

I have submit the issue: Named parameters support

xllance commented 1 year ago

You can use DynamicParameters Bag, which is basically a Dictictionary<string, object> like follows: connectionn.Execute("INSERT INTO TestTable (Id,Name) VALUES ($1,$2)", new Dictionary<string, object> { { "$1", 1 }, { "$2", "some string" } });

Seddryck commented 1 year ago

Sounds that named parameters are now supported by DuckDB: https://github.com/duckdb/duckdb/pull/5611

Giorgi commented 1 year ago

The necessary Api for named parameters isn't exposed in the C Api.

Giorgi commented 1 year ago

@Seddryck There is now a PR for this in DuckDB, once it gets merged and released it can be added to the library as well: Add support for named parameters in prepared statements

Giorgi commented 9 months ago

With the release of DuckDB 0.9.0, this is finally available (currently in the develop branch)