fix(qe-m2-03): normalize libpq-style options parameter to Search Path for Npgsql compatibility
This commit is contained in:
@@ -50,11 +50,25 @@ namespace QuantEngine.Core.Tests
|
|||||||
string? successfulConnStr = null;
|
string? successfulConnStr = null;
|
||||||
foreach (var rawDsn in candidates)
|
foreach (var rawDsn in candidates)
|
||||||
{
|
{
|
||||||
|
string connStr = rawDsn;
|
||||||
|
if (rawDsn.Contains("host=") || rawDsn.Contains("dbname="))
|
||||||
|
{
|
||||||
|
connStr = rawDsn
|
||||||
|
.Replace("options='-c search_path=quantengine'", "")
|
||||||
|
.Replace("options=\"-c search_path=quantengine\"", "")
|
||||||
|
.Replace("dbname=", "Database=")
|
||||||
|
.Replace("user=", "Username=")
|
||||||
|
.Replace("host=", "Host=")
|
||||||
|
.Replace("port=", "Port=")
|
||||||
|
.Trim();
|
||||||
|
connStr = string.Join(";", connStr.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)) + ";Search Path=quantengine";
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var conn = new NpgsqlConnection(rawDsn);
|
using var conn = new NpgsqlConnection(connStr);
|
||||||
await conn.OpenAsync();
|
await conn.OpenAsync();
|
||||||
successfulConnStr = rawDsn;
|
successfulConnStr = connStr;
|
||||||
break; // Found working connection
|
break; // Found working connection
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|||||||
Reference in New Issue
Block a user