JDBC string support
This commit is contained in:
parent
1d53ca2fc2
commit
0090f39910
7 changed files with 396 additions and 28 deletions
|
|
@ -21,18 +21,22 @@ public sealed class ConnectionStringService : IConnectionStringService
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a service pre-configured with built-in codecs (Libpq, Npgsql, Url).
|
||||
/// Creates a service pre-configured with built-in codecs (Libpq, Npgsql, Url, Jdbc).
|
||||
/// </summary>
|
||||
public static ConnectionStringService CreateDefault()
|
||||
=> new(new IConnectionStringCodec[] { new LibpqCodec(), new NpgsqlCodec(), new UrlCodec() });
|
||||
=> new(new IConnectionStringCodec[] { new LibpqCodec(), new NpgsqlCodec(), new UrlCodec(), new JdbcCodec() });
|
||||
|
||||
public Result<ConnStringFormat> DetectFormat(string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
return Result.Fail<ConnStringFormat>("Empty input");
|
||||
|
||||
// URL: postgresql:// or postgres://
|
||||
// URL: postgresql:// or postgres:// or JDBC jdbc:postgresql://
|
||||
var trimmed = input.TrimStart();
|
||||
if (trimmed.StartsWith("jdbc:postgresql://", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return Result.Ok(ConnStringFormat.Jdbc);
|
||||
}
|
||||
if (trimmed.StartsWith("postgresql://", StringComparison.OrdinalIgnoreCase) ||
|
||||
trimmed.StartsWith("postgres://", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue