Skip to content

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

Merged
merged 2 commits into from
Feb 14, 2022

Conversation

simPod
Copy link
Contributor

@simPod simPod commented Feb 4, 2022

Dbal V3 contains:

/**
 * Connection interface.
 * Driver connections must implement this interface.
 *
 * @method resource|object getNativeConnection()
 */
interface Connection

@simPod simPod force-pushed the native branch 6 times, most recently from 492647c to 022cef6 Compare February 4, 2022 16:04
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! 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

@simPod
Copy link
Contributor Author

simPod commented Feb 4, 2022 via email

@simPod simPod changed the base branch from master to develop February 5, 2022 21:55
@simPod
Copy link
Contributor Author

simPod commented Feb 5, 2022

@ste93cry how do you want to approach tests?

  1. TracingServerInfoAwareDriverConnectionTest fails because we moved method to @method so it cannot be mocked Add support for accessing dbal native connection #597 (comment)
  2. TracingDriverConnectionTest fails when run on dbal v2

@simPod simPod requested a review from ste93cry February 5, 2022 22:05
@ste93cry
Copy link
Contributor

ste93cry commented Feb 6, 2022

I think we can declare a NativeDriverConnectionInterface interface that extends TracingDriverConnectionInterface and declares the getNativeConnection() method. This class would be declared in the test file and we should mock it instead of the original one. The Doctrine team did the same here, so it should work

@simPod simPod force-pushed the native branch 2 times, most recently from 1eb94f9 to 84929c1 Compare February 7, 2022 08:09
@simPod
Copy link
Contributor Author

simPod commented Feb 7, 2022

Ok done

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.

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

@simPod simPod force-pushed the native branch 6 times, most recently from 4304784 to 25f08a1 Compare February 14, 2022 22:02
  Dbal V3 contains:

  ```php
  /**
   * Connection interface.
   * Driver connections must implement this interface.
   *
   * @method resource|object getNativeConnection()
   */
  interface Connection
  ```
@simPod
Copy link
Contributor Author

simPod commented Feb 14, 2022

Thanks for review, appreciate the strictnesss

@simPod
Copy link
Contributor Author

simPod commented Feb 14, 2022 via email

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 and the patience making all the changes! LGTM 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants