Skip to content
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

add DSN schemes for mysqli, oci8 and sqlsrv #1719

Closed
wants to merge 1 commit into from
Closed

add DSN schemes for mysqli, oci8 and sqlsrv #1719

wants to merge 1 commit into from

Conversation

MrMitch
Copy link

@MrMitch MrMitch commented Oct 27, 2023

This PR adds 3 schemes to be able to use the mysqli, oci8 and sqlsrv drivers in DSN configurations.

Adding mysqli provides another driver option for MySQL (in addition to pdo_mysql which can already be used with the mysql and mysql2 schemes).

Adding oci8 and sqlsrv improves developer experience because these drivers were previously not supported and the validation made in the Configuration class prevents these schemes from being overridden (even though they were not available !).

->arrayNode('driver_schemes')
->useAttributeAsKey('scheme')
->normalizeKeys(false)
->scalarPrototype()->end()
->info('Defines a driver for given URL schemes. Schemes being driver names cannot be redefined. However, other default schemes can be overwritten.')
->validate()
->always()
->then(static function (array $value) {
$unsupportedSchemes = [];
foreach ($value as $scheme => $driver) {
if (! in_array($scheme, ['pdo-mysql', 'pdo-sqlite', 'pdo-pgsql', 'pdo-oci', 'oci8', 'ibm-db2', 'pdo-sqlsrv', 'mysqli', 'pgsql', 'sqlsrv', 'sqlite3'], true)) {
continue;
}
$unsupportedSchemes[] = $scheme;
}
if ($unsupportedSchemes) {
throw new InvalidArgumentException(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()

Fixes #1718

@ostrolucky
Copy link
Member

This is just alias map. If driver is not found in this map, it will default to whatever you specify there. If oci8 is missing from this array, it doesn't mean oci8 driver is not supported. And mapping mysqli to pdo_mysql is especially nasty thing, because mysqli is separate driver from pdo_mysql

'postgres' => 'pdo_pgsql',
'postgresql' => 'pdo_pgsql',
'pgsql' => 'pdo_pgsql',
'sqlite' => 'pdo_sqlite',
'sqlite3' => 'pdo_sqlite',
'sqlsrv' => 'sqlsrv',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapping a value to itself is totally useless as alias, because there is no aliasing taking place.

@stof
Copy link
Member

stof commented Oct 28, 2023

I'm closing this because the suggested patch does not make sense. Those schemes already work as they correspond to the name of a DBAL driver.

@stof stof closed this Oct 28, 2023
@MrMitch
Copy link
Author

MrMitch commented Oct 28, 2023

@ostrolucky @stof you are correct, my issue was caused by something else.
Thank you for reviewing this and sorry for waisting your time.

@MrMitch MrMitch deleted the fix/1718 branch October 28, 2023 18:24
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.

Missing default schemes
3 participants