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

Driver::connect() should throw only driver-level exceptions #4072

Merged
merged 1 commit into from
Jun 13, 2020

Conversation

morozov
Copy link
Member

@morozov morozov commented Jun 13, 2020

Q A
Type improvement
BC Break yes

Summary

Currently, most of the Driver::connect() throw a DBALException on failure but some throw a DriverException exception. The lower level abstraction (drivers) should not be aware of the higher-level abstraction (DBAL). This way, instead of being implemented in one place, the higher-level logic gets inconsistently duplicated in multiple places.

Additional changes

  1. Driver::connect() is documented as @throws DriverException.
  2. Connection::connect() is documented as @throws DBALException.
  3. Connection::getDatabasePlatformVersion() will not expect Connection::connect() to throw anything else than a DBALException.

Testing

The code being changed is covered by existing tests (e.g. ExceptionTest::testConnectionException()). It doesn't look reasonable to add the unit tests that would cover the specific thrown exception types. Ideally, this should be tested statically (e.g. PhpStorm supports that but I'm not sure if other tools that can run on CI do).

@morozov morozov changed the title Driver::counect() should throw only driver-level exceptions Driver::connect() should throw only driver-level exceptions Jun 13, 2020
@greg0ire
Copy link
Member

greg0ire commented Jun 13, 2020

The patch coverage is ~ 50%… uncovered code seems to be related to OCI8, SqlAnywhere and Oracle. Do you think this is expected? Or is the AppVeyor report maybe not working properly?
0% coverage for SQLAnywhere\Driver::connect() looks really fishy, but I have to check which ones are supposed to be run on AppVeyor, and which ones on continuousPHP

@morozov
Copy link
Member Author

morozov commented Jun 13, 2020

The patch coverage is ~ 50%… uncovered code seems to be related to OCI8, SqlAnywhere and Oracle. Do you think this is expected?

Yes (#4075, #4076).

Or is the AppVeyor report maybe not working properly?

AppVeyor only covers SQL Server, not SQLAnywhere.

0% coverage for SQLAnywhere\Driver::connect() looks really fishy.

It's not tested anywhere and never was. We need to reconsider whether we want to support it. Unlike other commercial platforms like Oracle and DB2, there's no container available for testing. The driver is also not available on PECL but should be downloaded from their website (needs to be googled).

ContinuousPHP cannot send coverage to anything else than Scrutinizer. We took that into account when we migrated from it. I'd love to migrate from ContinuousPHP too but there's no clear path currently.

@morozov morozov merged commit 97fc7ff into doctrine:3.0.x Jun 13, 2020
@morozov morozov deleted the driver-connect-exceptions branch June 13, 2020 14:44
@morozov morozov self-assigned this Jun 13, 2020
@greg0ire
Copy link
Member

It's not tested anywhere

I'm late, but I see what you did here :)

@morozov morozov added this to the 3.0.0 milestone Jun 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants