Skip to content

Commit

Permalink
Add gel as a valid dsn scheme. (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark authored Nov 29, 2024
2 parents 62b6474 + b6187d3 commit 23b991a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/EdgeDB.Net.Driver/EdgeDBConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal bool ValidateServerCertificateCallback(object sender, X509Certificate?
/// <inheritdoc />
public override string ToString()
{
var str = "edgedb://";
var str = "gel://";

if (Username is not null)
str += Username;
Expand Down Expand Up @@ -269,8 +269,8 @@ public string CloudProfile
/// <exception cref="KeyNotFoundException">An environment variable couldn't be found.</exception>
public static EdgeDBConnection FromDSN(string dsn)
{
if (!dsn.StartsWith("edgedb://"))
throw new ConfigurationException("DSN schema 'edgedb' expected but got 'pq'");
if (!dsn.StartsWith("edgedb://") && !dsn.StartsWith("gel://"))
throw new ConfigurationException("DSN schema 'gel' expected but got 'pq'");

string? database = null, username = null, port = null, host = null, password = null;

Expand Down Expand Up @@ -644,7 +644,7 @@ public static EdgeDBConnection Parse(string? instance = null, string? dsn = null

// try to resolve the toml, don't do this for cloud-like conn params.
if (autoResolve && !((instance is not null && instance.Contains('/')) ||
(dsn is not null && !dsn.StartsWith("edgedb://"))))
(dsn is not null && !dsn.StartsWith("edgedb://") && !dsn.StartsWith("gel://"))))
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions tests/EdgeDB.Tests.Unit/ConnectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void DSNWithUnixSocket() =>
[TestMethod]
public void DSNRequiresEdgeDBSchema() =>
ExpectError<ConfigurationException>(ParseConnection("pq:///dbname?host=/unix_sock/test&user=spam"),
"DSN schema 'edgedb' expected but got 'pq'");
"DSN schema 'gel' expected but got 'pq'");

[TestMethod]
public void DSNQueryParameterWithUnixSocket() =>
Expand All @@ -156,7 +156,7 @@ public void TestConnectionFormat()
{
var connection = EdgeDBConnection.FromDSN("edgedb://user3:123123@localhost:5555/abcdef");

Assert.AreEqual("edgedb://user3:123123@localhost:5555/abcdef", connection.ToString());
Assert.AreEqual("gel://user3:123123@localhost:5555/abcdef", connection.ToString());
}

private static void Expect(Result result, EdgeDBConnection expected)
Expand Down

0 comments on commit 23b991a

Please sign in to comment.