Skip to content

Commit

Permalink
#120 Connection string DataSource key is case sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Iatsiuk committed Sep 17, 2023
1 parent b174409 commit 4ee9e41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace DuckDB.NET.Data.ConnectionString;
Expand Down Expand Up @@ -39,9 +40,13 @@ public static DuckDBConnectionString Parse(string connectionString)

private static string GetDataSource(IReadOnlyDictionary<string, string> properties)
{
var lowerCaseProperties = properties.ToDictionary(kv => kv.Value.ToLower(CultureInfo.InvariantCulture), kv => kv.Value);

foreach (var key in DuckDBConnectionStringBuilder.DataSourceKeys)
{
if (properties.TryGetValue(key, out var dataSource))
var lowerKey = key.ToLower(CultureInfo.InvariantCulture);

if (lowerCaseProperties.TryGetValue(lowerKey, out var dataSource))
{
return dataSource;
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDB.NET.Data/DuckDBConnectionStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class DuckDBConnectionStringBuilder : DbConnectionStringBuilder
public const string InMemorySharedDataSource = ":memory:?cache=shared";
public const string InMemorySharedConnectionString = "DataSource=:memory:?cache=shared";

internal static readonly string[] DataSourceKeys = {"Data Source", "DataSource", "datasource", "data source"};
internal static readonly string[] DataSourceKeys = {"Data Source", "DataSource"};
private const string DataSourceKey = "DataSource";

private string dataSource = null;
Expand Down

0 comments on commit 4ee9e41

Please sign in to comment.