Skip to content

Commit 977da30

Browse files
committed
Add accessor for wrapped DBAL Connection to TracingDriverConnection
Allows accessing e.g. underlying PDO instance so reflection does not have to be used for that. Mimics DBAL's `Connection::getWrappedConnection()`` https://github.com/doctrine/dbal/blob/25496429ef4bba2352b0ced7daffe1b3dec83d13/src/Connection.php#L1518-L1525
1 parent 426f45a commit 977da30

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Make the transport factory configurable in the bundle's config (#504)
66
- Add the `sentry_trace_meta()` Twig function to print the `sentry-trace` HTML meta tag (#510)
77
- Make the list of commands for which distributed tracing is active configurable (#515)
8+
- Introduce `TracingDriverConnection::getWrappedConnection()` (#536)
89

910
## 4.1.4 (2021-06-18)
1011

src/Tracing/Doctrine/DBAL/TracingDriverConnection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ public function errorInfo()
188188
throw new \BadMethodCallException(sprintf('The %s() method is not supported on Doctrine DBAL 3.0.', __METHOD__));
189189
}
190190

191+
public function getWrappedConnection(): DriverConnectionInterface
192+
{
193+
return $this->decoratedConnection;
194+
}
195+
191196
/**
192197
* @phpstan-template T
193198
*

tests/Tracing/Doctrine/DBAL/TracingDriverConnectionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ public function testRollBackDoesNothingIfNoSpanIsSetOnHub(): void
336336
$this->assertFalse($this->connection->rollBack());
337337
}
338338

339+
public function testGetWrappedConnection(): void
340+
{
341+
$connection = new TracingDriverConnection($this->hub, $this->decoratedConnection, 'foo_platform', []);
342+
343+
$this->assertSame($this->decoratedConnection, $connection->getWrappedConnection());
344+
}
345+
339346
/**
340347
* @return \Generator<mixed>
341348
*/

0 commit comments

Comments
 (0)