-
Notifications
You must be signed in to change notification settings - Fork 179
Add support for accessing dbal native connection #597
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
Conversation
492647c
to
022cef6
Compare
There was a problem hiding this 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! While making the required changes, please also add a CHANGELOG entry and the missing unit tests. For the latter, you can take a look at how they got implemented for the similar methods. Finally, please retarget the PR to the develop
branch as this is a feature and not a bug fix and will be released with the next minor version
Aight, thanks for review, you'll have it tomorrow evening CET
…On Fri, Feb 4, 2022, 23:27 Stefano Arlandini ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/Tracing/Doctrine/DBAL/TracingDriverConnection.php
<#597 (comment)>
:
> @@ -193,6 +194,15 @@ public function getWrappedConnection(): DriverConnectionInterface
return $this->decoratedConnection;
}
+ public function getNativeConnection()
+ {
+ if (!method_exists($this->decoratedConnection, 'getNativeConnection')) {
+ throw new LogicException(sprintf('The decoratedConnection %s does not support accessing the native connection.', \get_class($this->decoratedConnection)));
Yes please, we're always throwing a BadMethodCallException in similar
cases so I prefer to keep doing it here too for consistency. Moreover, I
don't think that a LogicException is appropriate to be honest as there is
no error of logic here, but just a method you're calling when you should
not. Message instead doesn't change much, it's just nitpicking 😃
—
Reply to this email directly, view it on GitHub
<#597 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACQAJKJYDOPK4ZQSLD6PHLUZRHGDANCNFSM5NSEQVMA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@ste93cry how do you want to approach tests?
|
I think we can declare a |
1eb94f9
to
84929c1
Compare
Ok done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add the missing testGetNativeConnectionThrowsExceptionIfDecoratedConnectionDoesNotImplementMethod
test method so that we cover the exception path? Note that since the class of the connection is anonymous, you should use expectExceptionMessageMatches
src/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnection.php
Outdated
Show resolved
Hide resolved
tests/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnectionTest.php
Show resolved
Hide resolved
4304784
to
25f08a1
Compare
Dbal V3 contains: ```php /** * Connection interface. * Driver connections must implement this interface. * * @method resource|object getNativeConnection() */ interface Connection ```
Thanks for review, appreciate the strictnesss |
Yup, it was phpstan
…On Mon, Feb 14, 2022, 23:33 Stefano Arlandini ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/Tracing/Doctrine/DBAL/TracingDriverConnection.php
<#597 (comment)>
:
> @@ -164,6 +165,20 @@ public function rollBack(): bool
});
}
+ /**
+ * ***@***.***}
+ *
+ * @return resource|object
Is PHPStan throwing this error? Weird, it should be able to read the
@method annotations 🤔 Anyway, it's not that important, it was just a
matter of not repeating the typehint
—
Reply to this email directly, view it on GitHub
<#597 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACQAJNVWFMKDN4M2JJBNU3U3F7LDANCNFSM5NSEQVMA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
There was a problem hiding this 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 and the patience making all the changes! LGTM 🥳
Dbal V3 contains: