Closed polettix closed 7 years ago
Afraid i can't accept this pull request without a test case.
Hi! Thanks for looking into it.
It seems that leveraging t/connection.t
should be the right thing to do, but there are a few ways I can think of right now:
t/connection.t
to use postgres
instead of postgresql
. This is much in the spirit don't leave this untested but assume there's nothing specific to the stringst/connection.t
, iterating over possible protocols postgresql
and postgres
. This is much in the spirit of do all the test again and refactor mercylesslypostgresql
over to postgres
, either in t/connection.t
itself (it checks for unsupported protocols in the last test after all) or in a separate t/connection-shortproto.t
standalone file. This is much in the spirit of do all the tests again but keep things as simple and plain as possibleDo you have a preference or some other way to suggest?
Summary
This PR allows Mojo::Pg to accept urls like
postgres://...
in addition topostgresql://...
. It helps complying with the generic setting for PostgreSQL, as e.g. stated here.This also helps reduce friction with automated systems that set urls in the former way, e.g. the Dokku plugin for PostgreSQL.
Motivation
This allows broader compliance to PostgreSQL rules and it is also a nice-to-have to avoid need for some munging e.g. in a Mojolicious application when receiving the
DATABASE_URL
parameter, like this:References
PostgreSQL documentation explicitly states that both URI scheme are good:
I hit this "impedance mismatch" while writing an article on deploying Perl applications on Dokku, you can find the article's relevant section here. This to say that there actually other softwares out there that decided to adopt the other way of expressing URLs.
Implementation
I chose to use regexps for compactness, TIMTOWTDI of course e.g.: