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

Add gel as a valid dsn scheme. #81

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
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
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
Loading