Giorgi / DuckDB.NET

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

Extract statements api #104

Closed Giorgi closed 1 year ago

Giorgi commented 1 year ago

Remaining tasks before it can be merged:

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 4780141643


Changes Missing Coverage Covered Lines Changed/Added Lines %
DuckDB.NET.Data/DuckDBDataReader.cs 41 42 97.62%
DuckDB.NET.Data/Internal/PreparedStatement.cs 16 19 84.21%
DuckDB.NET.Data/DuckDBCommand.cs 21 26 80.77%
<!-- Total: 87 96 90.63% -->
Files with Coverage Reduction New Missed Lines %
DuckDB.NET.Data/DuckDBDataReader.cs 1 90.73%
DuckDB.NET.Data/Internal/PreparedStatement.cs 9 80.15%
<!-- Total: 10 -->
Totals Coverage Status
Change from base Build 4629118895: -1.5%
Covered Lines: 733
Relevant Lines: 867

💛 - Coveralls
Seddryck commented 1 year ago

Hi Giorgi, I'm a bit not sure about the implementation but I'm clearly not a specialist of DuckDB so I could miss the point.

In ADO.Net the class DbCommand handles a single command, when you have multiple commands, it's the class DbBatch that is handling that. It doesn't sound too important but my fear is especially regarding the method ExecuteReader where the classical behaviour is impacted. Merging together the readers isn't intuitive for me and my experience of ADO.net

Giorgi commented 1 year ago

You definitely can execute multiple statements with a single command:

Retrieving multiple result sets using NextResult

Seddryck commented 1 year ago

Yes, correct. Nevertheless, .NET introduced the Batch API (materialized by the DbBatch class) a couple of years ago mainly because the feature to support multiple statements into a single DbCommand was clumsy. See https://www.infoq.com/news/2022/06/Database-Command-Batching/

In a modern ADO.Net provider, it sounds more suitable to implement this in a DbBatch class than a DbCommand class. If you want I can create a pull request with an implementation of DbBatch. Optionally, we could use the same trick as PostgreSQL to allow/deny this option on the DbCommand class (Probably won't be able to do it in the next two weeks).

Giorgi commented 1 year ago

Yes, it would be nice to implement the Batch API but I think it should be left in the DbCommand class too. Two weeks is perfectly OK, I plan to release a new version in May once DuckDB 0.8 is released. I'll create a ticket and you can assign it to you if you plan to work on it.

Giorgi commented 1 year ago

Created https://github.com/Giorgi/DuckDB.NET/issues/105