Skip to content

Commit 04a9e9d

Browse files
committed
fixup! DBAL3: Implement getServerVersion(), forwarding to PDOCrateDB
1 parent d89797a commit 04a9e9d

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/Crate/DBAL/Driver/PDOCrate/PDOConnection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ public function __construct($dsn, $user = null, $password = null, ?array $option
5252

5353
public function getServerVersion(): string
5454
{
55-
return $this->connection->getServerVersion();
55+
try {
56+
return $this->connection->getServerVersion();
57+
} catch (PDOException $exception) {
58+
throw Exception::new($exception);
59+
}
5660
}
5761

5862
public function getNativeConnection(): PDOCrateDB

test/Crate/Test/DBAL/Functional/ConnectionTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,23 @@ public function testConnect()
9696
$this->assertEquals('crate', $row['name']);
9797
}
9898

99-
public function testGetServerVersion()
99+
public function testGetServerVersionNativeConnection()
100100
{
101101
// Retrieve server version.
102102
$serverVersion = $this->_conn->getNativeConnection()->getServerVersion();
103+
$this->assertTrue(
104+
version_compare($serverVersion, '0.0.0', '>='),
105+
'Server version should be at least 0.0.0',
106+
);
107+
}
103108

104-
// Assume tests are running against CrateDB 5.x or higher, which is likely,
105-
// because it will mostly be running on CrateDB nightly.
106-
// Otherwise, we will need to populate this value from an external source,
107-
// for example an environment variable populated by a CI build matrix.
109+
public function testGetServerVersionWrappedConnection()
110+
{
111+
// Retrieve server version.
112+
$serverVersion = $this->_conn->getWrappedConnection()->getServerVersion();
108113
$this->assertTrue(
109-
version_compare($serverVersion, '5.0.0', '>='),
110-
'Server version should be at least 5.0.0',
114+
version_compare($serverVersion, '0.0.0', '>='),
115+
'Server version should be at least 0.0.0',
111116
);
112117
}
113118

0 commit comments

Comments
 (0)