You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that not all official drivers provided by Doctrine can be used in this bundle with a DSN. Only some drivers have an associated scheme registered in the ConnectionFactory class.
'mysql2' => 'pdo_mysql', // Amazon RDS, for some weird reason
'postgres' => 'pdo_pgsql',
'postgresql' => 'pdo_pgsql',
'pgsql' => 'pdo_pgsql',
'sqlite' => 'pdo_sqlite',
'sqlite3' => 'pdo_sqlite',
];
Imagine that you want to use the sqlsrv driver. By analogy with the other available drivers, I would expect the DSN for this driver to look like sqlsrv://user:password@host:port.
With the current configuration, using a DSN like this does not work because no driver is mapped to the sqlsrv scheme. In this case the default pdo_mysql driver is used.
Since doctrine/dbal:3.7.0 and doctrine/doctrine-bundle:2.10.0 we can add custom scheme-to-driver mappings with the doctrine.dbal.driver_schemes configuration option (made possible by doctrine/dbal#6059 and #1669).
However, if I try to register the sqlsrv scheme with the doctrine.dbal.driver_schemes option, the configuration fails because of the harcoded list of "official drivers" in the Configuration class.
thrownewInvalidArgumentException(sprintf('Registering a scheme with the name of one of the official drivers is forbidden, as those are defined in DBAL itself. The following schemes are forbidden: %s', implode(', ', $unsupportedSchemes)));
}
return$value;
})
->end()
->end()
The same limitation applies to the oci8 and mysqli official drivers which are absent from the default schemes listed in ConnectionFactory but forbidden in Configuration.
I would gladely prepare a PR to address this but I'd rather ask for the direction you would prefer to go beforehand
One way to fix this would be to add a few entries to ConnectionFactory::DEFAULT_SCHEME_MAP to enable default support for the missing drivers. This seems to me like the prefered option because it enables more official drivers out of the box. I find it strange that no driver is available to use with a DNS by default for SQL Server and OCI.
Alternatively, the affected drivers could be removed form the hardcoded list in the Configuration class, leaving the responsability to every project needing them to register the drivers manually.
Thank you for taking the time to read this.
The text was updated successfully, but these errors were encountered:
Hi,
I've noticed that not all official drivers provided by Doctrine can be used in this bundle with a DSN. Only some drivers have an associated scheme registered in the
ConnectionFactory
class.DoctrineBundle/ConnectionFactory.php
Lines 29 to 39 in f549108
Imagine that you want to use the
sqlsrv
driver. By analogy with the other available drivers, I would expect the DSN for this driver to look likesqlsrv://user:password@host:port
.With the current configuration, using a DSN like this does not work because no driver is mapped to the
sqlsrv
scheme. In this case the defaultpdo_mysql
driver is used.Since
doctrine/dbal:3.7.0
anddoctrine/doctrine-bundle:2.10.0
we can add custom scheme-to-driver mappings with thedoctrine.dbal.driver_schemes
configuration option (made possible by doctrine/dbal#6059 and #1669).However, if I try to register the
sqlsrv
scheme with thedoctrine.dbal.driver_schemes
option, the configuration fails because of the harcoded list of "official drivers" in theConfiguration
class.DoctrineBundle/DependencyInjection/Configuration.php
Lines 141 to 166 in f549108
The same limitation applies to the
oci8
andmysqli
official drivers which are absent from the default schemes listed inConnectionFactory
but forbidden inConfiguration
.I would gladely prepare a PR to address this but I'd rather ask for the direction you would prefer to go beforehand
One way to fix this would be to add a few entries to
ConnectionFactory::DEFAULT_SCHEME_MAP
to enable default support for the missing drivers. This seems to me like the prefered option because it enables more official drivers out of the box. I find it strange that no driver is available to use with a DNS by default for SQL Server and OCI.Alternatively, the affected drivers could be removed form the hardcoded list in the
Configuration
class, leaving the responsability to every project needing them to register the drivers manually.Thank you for taking the time to read this.
The text was updated successfully, but these errors were encountered: