Skip to content

Discrepancy between NpgsqlConnectionStringBuilder.Keys and NpgsqlConnectionStringBuilder.ContainsKey #6463

@KeterSCP

Description

@KeterSCP

I need to determine whether pooling was explicitly set on the base connection string. I thought I could do that by using NpgsqlConnectionStringBuilder.ContainsKey, however it always returns true.

Repro:

const string connectionString = "Server=localhost;Port=5432;Database=db;User Id=postgres;Password=postgres;";

var csBuilder = new NpgsqlConnectionStringBuilder(connectionString);

Console.WriteLine($"ContainsKey Pooling: {csBuilder.ContainsKey("Pooling")}");

Console.WriteLine("== Keys ==");
foreach (var builderKey in csBuilder.Keys)
{
    Console.WriteLine(builderKey);
}

Output:

ContainsKey Pooling: True
== Keys ==
Host
Port
Database
Username
Password

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions