Giorgi / DuckDB.NET

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

Connection string DataSource key is case sensitive #120

Closed roee88 closed 1 year ago

roee88 commented 1 year ago

The current codebase assumes DataSource or Data Source as the data source key in a connection string and fails for lower case variants in https://github.com/Giorgi/DuckDB.NET/blob/f933d9b7912a981399f4dd382a5695446d01ba5c/DuckDB.NET.Data/ConnectionString/DuckDBConnectionStringParser.cs#L20

When using a builder to set a connection string (e.g., to perform validation and avoid the possibility of getting errors like IndexOutOfBoundsException when setting it directly), the keys are changed to lower case. For example if connectionString is set to DataSource=:memory: then the following code will set it to datasource=:memory:

var builder = DbProviderFactories.GetFactory(DuckDBClientFactory.ProviderInvariantName).CreateConnectionStringBuilder();
builder!.ConnectionString = connectionString;
connectionString = builder.ConnectionString;

Consider adding support for case insensitive keys.

Giorgi commented 1 year ago

Feel free to send a PR for this if you are interested.