Skip to content

Refactor connection managers to shared base; add identifier quoting and DuckDB parameter support#17

Closed
Dagalon wants to merge 4 commits into
developfrom
codex/limpiar-comentarios-en-duckdb-qcmtmp
Closed

Refactor connection managers to shared base; add identifier quoting and DuckDB parameter support#17
Dagalon wants to merge 4 commits into
developfrom
codex/limpiar-comentarios-en-duckdb-qcmtmp

Conversation

@Dagalon

@Dagalon Dagalon commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Consolidate thread-safe connection management and avoid duplicated connection dictionary logic across database backends by introducing a reusable base class.
  • Harden SQL generation by properly quoting identifiers to prevent injection/invalid names and make DuckDB attachment/DDL robust.
  • Support parameterized queries for DuckDB and improve resource disposal semantics to avoid leaked commands/readers.

Description

  • Add ConnectionManagerBase<TConnection> in Shared/ConnectionManagerBase.cs and update SqliteDB-Memory-Lib/ConnectionManager.cs and DuckDB-Memory-Lib/ConnectionManager.cs to inherit from the base and delegate connection creation via GetConnectionCore.
  • Replace the DuckDB project package with DuckDB.NET.Data.Full 1.4.4 and link the shared ConnectionManagerBase.cs into both projects via the .csproj changes.
  • Improve SQL safety by using DuckTools.QuoteIdentifier for database/table/column names, update DuckTools.AttachDatabase to quote aliases, and fix QueryExecutor to build quoted table names.
  • Use using statements for DuckDBCommand/readers and implement parameter binding in QueryExecutor.ExecuteQryReader(...) by creating parameters via CreateParameter and normalizing names with NormalizeParameterName.
  • Fix KeeperRegisterIdDataBase.DeleteRegister to locate and remove entries using FirstOrDefault with case-insensitive value comparison and guard against missing keys.

Testing

  • Ran unit tests via dotnet test for the DuckDB test project including T_QuoteIdentifier_And_ParameterName_Return_Safe_Sql_Tokens, T_DeleteRegister_Ignores_Missing_Id, and T_CreateTable_Quotes_Database_And_Table_Identifiers, and they passed.
  • Executed parquet table integration test T_Create_Table_From_Parquet which succeeded using the updated DuckDB library and quoted identifiers.
  • Ran the new parameter test T_ExecuteQryReader_Uses_DuckDb_Parameters which validated parameterized queries and returned expected results.

Codex Task

@Dagalon Dagalon closed this Jul 7, 2026
@Dagalon Dagalon deleted the codex/limpiar-comentarios-en-duckdb-qcmtmp branch July 7, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant