-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Deprecate driver name aliases #5697
Conversation
Even worse: So 👍🏻 from my side! |
e1147ab
to
3cedf31
Compare
I believe at some point the DBAL supported a non-PDO version of the SQLite or PostgreSQL driver. Not sure what happened but unless it brings in some maintenance issues, I don't see a problem adding it. In my experience, the non-PDO drivers provide a nicer API and allow the usage of more features (says a maintainer of the DBAL). |
the purpose of those aliases was to support credential URLs provided by common PaaS or IaaS platforms, to make it easier to use doctrine/dbal on them (without having to build a scheme-remapping system in the reading of env variables. Those hosting providers are not aware of doctrine/dbal when exposing those URLs (those hosting providers are often not even specific to PHP) |
The problem is that for each database engine (with the exception of Postgres currently) we have two possible drivers that can connect to that database. And it could be more if the application used a custom driver. The decision which of those drivers to use should be made deliberately by the application, especially if the application accesses the native connection in some situations. Right now, the driver being used is the result of a chain of coincidences. Even worse: Some of the aliases are identical to the name of an existing PHP extension (like I understand the problem, but I would still support the deprecation of those hardcoded aliases. If guessing DBAL connection settings from generic database DSNs is a common problem, maybe we can think about moving the DSN parsing to a dedicated class and provide a way to map schemes to drivers. Alternatively, framework integration layers like DoctrineBundle could take over this task. |
If we specify the |
The aliases were initially implemented in #729 as part of the support for connection URLs but there wasn't any public discussion about their design and purpose.
The existing set of aliases is quite illogical and raises questions:
mysql
alias prefers thepdo_mysql
driver overmysqli
. Why?sqlsrv
in the schema will make thesqlsrv
driver used whilemssql
is mapped topdo_sqlsrv
. Why?mysql2
alias was introduced fordbal/src/DriverManager.php
Line 101 in 2ab7855
Judging by the documentation, the only purpose of using an alias is to avoid using dashes or underscores in connection URLs. Even if that's the case, why do we need more than one alias per driver name? Being able to do one thing in four different ways (
pgsql
,postgres
,postgresql
,pdo-pgsql
) has rarely been a good idea.Given that the requirement for using dashes has been documented since the very beginning, I don't believe that this is a problem that requires support for aliases.