Skip to content

Commit 5975a28

Browse files
committed
Connection: added getDriver() as alias for getSupplementalDriver()
1 parent e28bf02 commit 5975a28

25 files changed

+43
-35
lines changed

src/Database/Connection.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ public function getPdo(): PDO
106106
}
107107

108108

109+
public function getDriver(): Driver
110+
{
111+
$this->connect();
112+
return $this->driver;
113+
}
114+
115+
116+
/** @deprecated use getDriver() */
109117
public function getSupplementalDriver(): Driver
110118
{
111119
$this->connect();

src/Database/ResultSet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function __construct(Connection $connection, string $queryString, array $
7070
@$this->pdoStatement->execute(); // @ PHP generates warning when ATTR_ERRMODE = ERRMODE_EXCEPTION bug #73878
7171
}
7272
} catch (\PDOException $e) {
73-
$e = $connection->getSupplementalDriver()->convertException($e);
73+
$e = $connection->getDriver()->convertException($e);
7474
$e->queryString = $queryString;
7575
$e->params = $params;
7676
throw $e;
@@ -130,7 +130,7 @@ public function getTime(): float
130130
public function normalizeRow(array $row): array
131131
{
132132
if ($this->types === null) {
133-
$this->types = $this->connection->getSupplementalDriver()->getColumnTypes($this->pdoStatement);
133+
$this->types = $this->connection->getDriver()->getColumnTypes($this->pdoStatement);
134134
}
135135

136136
foreach ($this->types as $key => $type) {

src/Database/SqlPreprocessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class SqlPreprocessor
7575
public function __construct(Connection $connection)
7676
{
7777
$this->connection = $connection;
78-
$this->driver = $connection->getSupplementalDriver();
78+
$this->driver = $connection->getDriver();
7979
}
8080

8181

src/Database/Structure.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getPrimaryKeySequence(string $table): ?string
100100
$this->needStructure();
101101
$table = $this->resolveFQTableName($table);
102102

103-
if (!$this->connection->getSupplementalDriver()->isSupported(Driver::SUPPORT_SEQUENCE)) {
103+
if (!$this->connection->getDriver()->isSupported(Driver::SUPPORT_SEQUENCE)) {
104104
return null;
105105
}
106106

@@ -183,7 +183,7 @@ protected function needStructure(): void
183183

184184
protected function loadStructure(): array
185185
{
186-
$driver = $this->connection->getSupplementalDriver();
186+
$driver = $this->connection->getDriver();
187187

188188
$structure = [];
189189
$structure['tables'] = $driver->getTables();
@@ -241,7 +241,7 @@ protected function analyzeForeignKeys(array &$structure, string $table): void
241241
{
242242
$lowerTable = strtolower($table);
243243

244-
$foreignKeys = $this->connection->getSupplementalDriver()->getForeignKeys($table);
244+
$foreignKeys = $this->connection->getDriver()->getForeignKeys($table);
245245

246246
$fksColumnsCounts = [];
247247
foreach ($foreignKeys as $foreignKey) {

src/Database/Table/Selection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ public function insert(iterable $data)
824824

825825
// First check sequence
826826
if (!empty($primarySequenceName) && $primaryAutoincrementKey) {
827-
$primaryKey[$primaryAutoincrementKey] = $this->explorer->getInsertId($this->explorer->getConnection()->getSupplementalDriver()->delimite($primarySequenceName));
827+
$primaryKey[$primaryAutoincrementKey] = $this->explorer->getInsertId($this->explorer->getConnection()->getDriver()->delimite($primarySequenceName));
828828

829829
// Autoincrement primary without sequence
830830
} elseif ($primaryAutoincrementKey) {

src/Database/Table/SqlBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class SqlBuilder
9696
public function __construct(string $tableName, Explorer $explorer)
9797
{
9898
$this->tableName = $tableName;
99-
$this->driver = $explorer->getConnection()->getSupplementalDriver();
99+
$this->driver = $explorer->getConnection()->getDriver();
100100
$this->conventions = $explorer->getConventions();
101101
$this->structure = $explorer->getStructure();
102102
$tableNameParts = explode('.', $tableName);

tests/Database/Connection.lazy.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@ test('connect & disconnect', function () {
5353

5454
// first connection
5555
$pdo = $connection->getPdo();
56-
$driver = $connection->getSupplementalDriver();
56+
$driver = $connection->getDriver();
5757
Assert::same(1, $connections);
5858

5959
// still first connection
6060
$connection->connect();
6161
Assert::same($pdo, $connection->getPdo());
62-
Assert::same($driver, $connection->getSupplementalDriver());
62+
Assert::same($driver, $connection->getDriver());
6363
Assert::same(1, $connections);
6464

6565
// second connection
6666
$connection->reconnect();
6767
$pdo2 = $connection->getPdo();
68-
$driver2 = $connection->getSupplementalDriver();
68+
$driver2 = $connection->getDriver();
6969

7070
Assert::notSame($pdo, $pdo2);
7171
Assert::notSame($driver, $driver2);
@@ -74,6 +74,6 @@ test('connect & disconnect', function () {
7474
// third connection
7575
$connection->disconnect();
7676
Assert::notSame($pdo2, $connection->getPdo());
77-
Assert::notSame($driver2, $connection->getSupplementalDriver());
77+
Assert::notSame($driver2, $connection->getDriver());
7878
Assert::same(3, $connections);
7979
});

tests/Database/Drivers/MySqlDriver.applyLimit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use Tester\Assert;
1111
require __DIR__ . '/../connect.inc.php'; // create $connection
1212

1313

14-
$driver = $connection->getSupplementalDriver();
14+
$driver = $connection->getDriver();
1515

1616
$query = 'SELECT 1 FROM t';
1717
$driver->applyLimit($query, 10, 20);

tests/Database/Drivers/MySqlDriver.formatLike.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use Tester\Assert;
1111
require __DIR__ . '/../connect.inc.php'; // create $connection
1212

1313

14-
$driver = $connection->getSupplementalDriver();
14+
$driver = $connection->getDriver();
1515

1616
Assert::same(0, $connection->query("SELECT 'AAxBB' LIKE", $connection::literal($driver->formatLike('A_B', 0)))->fetchField());
1717
Assert::same(1, $connection->query("SELECT 'AA_BB' LIKE", $connection::literal($driver->formatLike('A_B', 0)))->fetchField());

tests/Database/Drivers/PgSqlDriver.formatLike.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require __DIR__ . '/../connect.inc.php'; // create $connection
1212

1313

1414
$tests = function ($connection) {
15-
$driver = $connection->getSupplementalDriver();
15+
$driver = $connection->getDriver();
1616

1717
Assert::false($connection->query("SELECT 'AAxBB' LIKE", $connection::literal($driver->formatLike('A_B', 0)))->fetchField());
1818
Assert::true($connection->query("SELECT 'AA_BB' LIKE", $connection::literal($driver->formatLike('A_B', 0)))->fetchField());
@@ -27,7 +27,7 @@ $tests = function ($connection) {
2727
Assert::true($connection->query("SELECT 'AA\"BB' LIKE", $connection::literal($driver->formatLike('A"B', 0)))->fetchField());
2828
};
2929

30-
$driver = $connection->getSupplementalDriver();
30+
$driver = $connection->getDriver();
3131
$connection->query('SET escape_string_warning TO off'); // do not log warnings
3232

3333
$connection->query('SET standard_conforming_strings TO on');

0 commit comments

Comments
 (0)