Skip to content

impossible to configure LogicalReplicationConnection from a given NpgsqlConnection without persisting security information. #5970

@ahmednfwela

Description

@ahmednfwela

Given a NpgsqlConnection that's already configured, we used to be able to create a new connection from it by calling CloneWith, or casting it to ICloneable then calling Clone.

However it's not possible to do this with LogicalReplicationConnection, since its only way of configuration is passing a connection string, leaving us having to enable Persist Security Info=true.

I would suggest introducing a copy constructor to solve this:

public ReplicationConnection(NpgsqlConnection connection) { /*...*/ }
public LogicalReplicationConnection(NpgsqlConnection connection) { /*...*/ }

Further technical details

Npgsql version: latest (v9)

/// <summary>
/// Initializes a new instance of <see cref="LogicalReplicationConnection"/>.
/// </summary>
public LogicalReplicationConnection() {}
/// <summary>
/// Initializes a new instance of <see cref="LogicalReplicationConnection"/> with the given connection string.
/// </summary>
/// <param name="connectionString">The connection used to open the PostgreSQL database.</param>
public LogicalReplicationConnection(string? connectionString) : base(connectionString) {}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions