Skip to content

Conversation

@hernan604
Copy link

@hernan604 hernan604 commented Jan 1, 2026

…h part. this allows unix paths as the hostname. example: postgresql://user:@/var/run/postgresql:5432/MY_DB_NAME

Summary

Allow "file paths" as hostname on the dsn.

Example: postgresql://user:@/var/run/postgresql:5432/db_name

Host should be: /var/run/postgresql
DB should be = "db_name"

However, since it grabs the first path part, it considers the db name = "var" as seen in the following test:

#   Failed test 'got the expected dsn result: dbi:Pg:dbname=db_name'
#   at /home/administrator/dev/mojo-pg/t/dsn.t line 47.
#          got: 'dbi:Pg:dbname=var'
#     expected: 'dbi:Pg:dbname=db_name'
# Looks like you failed 1 test of 7.

Motivation

EXPLAIN WHY YOU BELIEVE THESE CHANGES ARE NECESSARY HERE

References

LIST RELEVANT ISSUES, PULL REQUESTS AND FORUM DISCUSSIONS HERE

@hernan604 hernan604 force-pushed the dsn_-_accept_path_as_host branch from 3d0d990 to c89bc92 Compare January 1, 2026 07:54
@kraih
Copy link
Member

kraih commented Jan 1, 2026

There's already a connection.t file. With a much cleaner layout.

…h part. this allows unix paths as the hostname. example: postgresql://user:@/var/run/postgresql:5432/MY_DB_NAME
@hernan604 hernan604 force-pushed the dsn_-_accept_path_as_host branch from c89bc92 to 3ee8553 Compare January 1, 2026 20:37
@hernan604
Copy link
Author

hernan604 commented Jan 1, 2026

There's already a connection.t file. With a much cleaner layout.

Nice, thanks for that ! I have moved the relevant tests to connection.t

I think this solves part of the problem to be able to use a "file path" as host in the connection string. However, the "host/port" are not detected and also not in the generated "dsn" because of the way Mojo::URL parses using the official regex from RFC 3986 https://github.com/mojolicious/mojo/blob/main/lib/Mojo/URL.pm#L55 ... as seen in test 3ee8553#diff-539ef6730bfa20f7792e8b643d382f181bffc1984fafe4fe7fd506614402814cR96-R97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants