Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Version directly from postgres driver #291

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions FAnsiSql/Implementations/PostgreSql/PostgreSqlServerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public sealed class PostgreSqlServerHelper : DiscoveredServerHelper
{
public static readonly PostgreSqlServerHelper Instance = new();

private PostgreSqlServerHelper() : base(DatabaseType.PostgreSql)
{
}
Expand Down Expand Up @@ -47,16 +48,11 @@

public override string? GetExplicitPasswordIfAny(DbConnectionStringBuilder builder) => ((NpgsqlConnectionStringBuilder)builder).Password;

public override Version? GetVersion(DiscoveredServer server)
public override Version GetVersion(DiscoveredServer server)
{
using var con = server.GetConnection();
using var con = new NpgsqlConnection(server.Builder.ConnectionString);
con.Open();
using var cmd = server.GetCommand("SHOW server_version", con);
using var r = cmd.ExecuteReader();
if (r.Read())
return r[0] == DBNull.Value ? null : CreateVersionFromString((string)r[0]);

return null;
return con.PostgreSqlVersion;
}


Expand Down Expand Up @@ -93,7 +89,7 @@

public override DbConnection GetConnection(DbConnectionStringBuilder builder) => new NpgsqlConnection(builder.ConnectionString);

protected override DbConnectionStringBuilder GetConnectionStringBuilderImpl(string server, string database,

Check warning on line 92 in FAnsiSql/Implementations/PostgreSql/PostgreSqlServerHelper.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of type of parameter 'database' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 92 in FAnsiSql/Implementations/PostgreSql/PostgreSqlServerHelper.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of type of parameter 'database' doesn't match overridden member (possibly because of nullability attributes).
string username, string password)
{
var toReturn = new NpgsqlConnectionStringBuilder
Expand Down
Loading