Repository navigation
Support URI-like connection strings (postgres://) - #2512
jgilchrist wants to merge 1 commit into
Conversation
|
The approach looks good to me - as far as I'm concerned you can move forward with a more complete PR.
I don't think it makes sense to add this dependency only for parsing query string parameters. Parsing these manually shouldn't extremely hard...
Ideally yes... One more thought: PostgreSQL has a set of recognized keywords, which don't necessarily correspond to what we currently support via NpgsqlConnectionStringBuilder. If the goal here is to allow using PG URIs as-is, then we should probably think about recognizing these as well, and mapping them to our connection string parameters. This could be done by annotating properties on NpgsqlConnectionStringBuilder with new attributes for their URI keyword, and use reflection to extract them. |
austindrenski
left a comment
There was a problem hiding this comment.
Excited to see this moving forward. Just some initial thoughts.
|
|
||
| NpgsqlConnectionStringBuilder ParseConnectionString(string connectionString) | ||
| { | ||
| return Uri.TryCreate(connectionString, UriKind.Absolute, out var uri) |
There was a problem hiding this comment.
We should probably also check that the scheme is postgres:// or postgresql://.
| { | ||
| var builder = new NpgsqlConnectionStringBuilder(); | ||
|
|
||
| var userInfo = uri.UserInfo?.Split(':'); |
There was a problem hiding this comment.
I think we'll also need to unescape some values here.
|
A very belated thanks for the reviews here everyone - unfortunately I didn't get a lot of time to follow up on this but it seems a more fleshed-out PR has been filed here: #2733 so I'm going to close this out |
|
Thanks @jgilchrist! |
This is a first attempt at a solution for #2090. It may be way off base and it's not yet complete (it doesn't handle query parameters yet for example) but I wanted to file this to get some initial feedback on the direction so I can course correct if this doesn't look like the right way to go.
A couple of thoughts
NpgsqlConnection.ConnectionString,NpgsqlConnection._connectionString,NpgsqlConnection._userFacingConnectionString,NpgsqlConnectionStringBuilder.ConnectionString). As far as I can tell, line 267 would need to know whether the initial connection string was passed as a URI and would need to call a differentToString...method?System.Webin .NET Framework, but is inMicrosoft.AspNetCore.WebUtilitiesfor .NET Core - is this a dependency that would be OK to add?