Skip to content

fix(types): added nullability to getDatabase method #541

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

Merged
merged 2 commits into from
Aug 16, 2021

Conversation

santoslluis
Copy link
Contributor

If getDatabase doesn't allow null return values, it will fail when the Driver returns null for this method.

It happens in https://github.com/webmozart/doctrine-dbal/blob/master/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php#L114 when using DATABASE_URL="sqlite:///:memory:"

this is weird because in-memory dbs are usually used in a test environments were sentry is deactivated, but this class is still being loaded and throws errors in all the tests.

I get the following error in all the tests:
TypeError : Return value of Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriver::getDatabase() must be of the type string, null returned

with this change it works for me.

If getDatabase doesn't allow null return values, it will fail when the Driver returns null for this method.

It happens in https://github.com/webmozart/doctrine-dbal/blob/master/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php#L114 when using `DATABASE_URL="sqlite:///:memory:"`

this is weird because in-memory dbs are usually used in a test environments were sentry is deactivated, but this class is still being loaded and throws errors in all the tests. 

I get the following error in all the tests:
`TypeError : Return value of Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriver::getDatabase() must be of the type string, null returned`

with this change it works for me.
@ste93cry
Copy link
Contributor

ste93cry commented Aug 16, 2021

Thank you for catching this bug, I just had a look at the PHPDoc of that method and it doesn't mention null so that's why it was like it was. Can you please add an entry to the CHANGELOG with a reference to this PR 🙏?

@ste93cry ste93cry added this to the 4.2 milestone Aug 16, 2021
@santoslluis
Copy link
Contributor Author

Thank you for catching this bug, I just take a look at the PHPDoc of that method and it doesn't mention null so that's why it was like it was. Can you please add an entry to the CHANGELOG with a reference to this PR pray?

sure

Copy link
Contributor

@ste93cry ste93cry left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution, LGTM 🥳

@ste93cry ste93cry merged commit dc611e5 into getsentry:master Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants