Skip to content

Commit e28bf02

Browse files
committed
renamed ISupplementalDriver -> Driver
1 parent 356378f commit e28bf02

23 files changed

+66
-44
lines changed

src/Database/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Connection
3333
/** @var array */
3434
private $options;
3535

36-
/** @var ISupplementalDriver */
36+
/** @var Driver */
3737
private $driver;
3838

3939
/** @var SqlPreprocessor */
@@ -106,7 +106,7 @@ public function getPdo(): PDO
106106
}
107107

108108

109-
public function getSupplementalDriver(): ISupplementalDriver
109+
public function getSupplementalDriver(): Driver
110110
{
111111
$this->connect();
112112
return $this->driver;

src/Database/ISupplementalDriver.php renamed to src/Database/Driver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Supplemental PDO database driver.
1515
*/
16-
interface ISupplementalDriver
16+
interface Driver
1717
{
1818
public const
1919
SUPPORT_SEQUENCE = 'sequence',
@@ -95,3 +95,6 @@ function getColumnTypes(\PDOStatement $statement): array;
9595
*/
9696
function isSupported(string $item): bool;
9797
}
98+
99+
100+
interface_exists(ISupplementalDriver::class);

src/Database/Drivers/MsSqlDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Supplemental MS SQL database driver.
1717
*/
18-
class MsSqlDriver implements Nette\Database\ISupplementalDriver
18+
class MsSqlDriver implements Nette\Database\Driver
1919
{
2020
use Nette\SmartObject;
2121

src/Database/Drivers/MySqlDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Supplemental MySQL database driver.
1717
*/
18-
class MySqlDriver implements Nette\Database\ISupplementalDriver
18+
class MySqlDriver implements Nette\Database\Driver
1919
{
2020
use Nette\SmartObject;
2121

src/Database/Drivers/OciDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Supplemental Oracle database driver.
1717
*/
18-
class OciDriver implements Nette\Database\ISupplementalDriver
18+
class OciDriver implements Nette\Database\Driver
1919
{
2020
use Nette\SmartObject;
2121

src/Database/Drivers/OdbcDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Supplemental ODBC database driver.
1717
*/
18-
class OdbcDriver implements Nette\Database\ISupplementalDriver
18+
class OdbcDriver implements Nette\Database\Driver
1919
{
2020
use Nette\SmartObject;
2121

src/Database/Drivers/PgSqlDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Supplemental PostgreSQL database driver.
1717
*/
18-
class PgSqlDriver implements Nette\Database\ISupplementalDriver
18+
class PgSqlDriver implements Nette\Database\Driver
1919
{
2020
use Nette\SmartObject;
2121

src/Database/Drivers/SqliteDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Supplemental SQLite3 database driver.
1717
*/
18-
class SqliteDriver implements Nette\Database\ISupplementalDriver
18+
class SqliteDriver implements Nette\Database\Driver
1919
{
2020
use Nette\SmartObject;
2121

src/Database/Drivers/SqlsrvDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Supplemental SQL Server 2005 and later database driver.
1717
*/
18-
class SqlsrvDriver implements Nette\Database\ISupplementalDriver
18+
class SqlsrvDriver implements Nette\Database\Driver
1919
{
2020
use Nette\SmartObject;
2121

src/Database/SqlPreprocessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SqlPreprocessor
5353
/** @var Connection */
5454
private $connection;
5555

56-
/** @var ISupplementalDriver */
56+
/** @var Driver */
5757
private $driver;
5858

5959
/** @var array of input parameters */
@@ -220,7 +220,7 @@ private function formatValue($value, string $mode = null): string
220220
}
221221
$vx[] = implode(', ', $vx2);
222222
}
223-
$select = $this->driver->isSupported(ISupplementalDriver::SUPPORT_MULTI_INSERT_AS_SELECT);
223+
$select = $this->driver->isSupported(Driver::SUPPORT_MULTI_INSERT_AS_SELECT);
224224
return '(' . implode(', ', $kx) . ($select ? ') SELECT ' : ') VALUES (')
225225
. implode($select ? ' UNION ALL SELECT ' : '), (', $vx) . ($select ? '' : ')');
226226
}

src/Database/Structure.php

Lines changed: 1 addition & 1 deletion
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(ISupplementalDriver::SUPPORT_SEQUENCE)) {
103+
if (!$this->connection->getSupplementalDriver()->isSupported(Driver::SUPPORT_SEQUENCE)) {
104104
return null;
105105
}
106106

src/Database/Table/SqlBuilder.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
namespace Nette\Database\Table;
1111

1212
use Nette;
13+
use Nette\Database\Driver;
1314
use Nette\Database\Explorer;
1415
use Nette\Database\IConventions;
1516
use Nette\Database\IStructure;
16-
use Nette\Database\ISupplementalDriver;
1717
use Nette\Database\SqlLiteral;
1818

1919

@@ -80,7 +80,7 @@ class SqlBuilder
8080
/** @var string currently parsing alias for joins */
8181
protected $currentAlias;
8282

83-
/** @var ISupplementalDriver */
83+
/** @var Driver */
8484
private $driver;
8585

8686
/** @var IStructure */
@@ -160,7 +160,7 @@ public function getSelectQueryHash(array $columns = null): string
160160
$parts[] = $this->select;
161161
} elseif ($columns) {
162162
$parts[] = [$this->delimitedTable, $columns];
163-
} elseif ($this->group && !$this->driver->isSupported(ISupplementalDriver::SUPPORT_SELECT_UNGROUPED_COLUMNS)) {
163+
} elseif ($this->group && !$this->driver->isSupported(Driver::SUPPORT_SELECT_UNGROUPED_COLUMNS)) {
164164
$parts[] = [$this->group];
165165
} else {
166166
$parts[] = "{$this->delimitedTable}.*";
@@ -210,7 +210,7 @@ function ($col) { return "$this->tableName.$col"; },
210210
}
211211
$querySelect = $this->buildSelect($cols);
212212

213-
} elseif ($this->group && !$this->driver->isSupported(ISupplementalDriver::SUPPORT_SELECT_UNGROUPED_COLUMNS)) {
213+
} elseif ($this->group && !$this->driver->isSupported(Driver::SUPPORT_SELECT_UNGROUPED_COLUMNS)) {
214214
$querySelect = $this->buildSelect([$this->group]);
215215
$this->parseJoins($joins, $querySelect);
216216

@@ -361,7 +361,7 @@ protected function addCondition($condition, array $params, array &$conditions, a
361361
}
362362
}
363363

364-
if ($this->driver->isSupported(ISupplementalDriver::SUPPORT_SUBSELECT)) {
364+
if ($this->driver->isSupported(Driver::SUPPORT_SUBSELECT)) {
365365
$arg = null;
366366
$subSelectPlaceholderCount = substr_count($clone->getSql(), '?');
367367
$replace = $match[2][0] . '(' . $clone->getSql() . (!$subSelectPlaceholderCount && count($clone->getSqlBuilder()->getParameters()) === 1 ? ' ?' : '') . ')';
@@ -629,7 +629,7 @@ public function parseJoinsCb(&$joins, $match): string
629629
$parentAlias = preg_replace('#^(.*\.)?(.*)$#', '$2', $this->tableName);
630630

631631
// join schema keyMatch and table keyMatch to schema.table keyMatch
632-
if ($this->driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA) && count($keyMatches) > 1) {
632+
if ($this->driver->isSupported(Driver::SUPPORT_SCHEMA) && count($keyMatches) > 1) {
633633
$tables = $this->getCachedTableList();
634634
if (
635635
!isset($tables[$keyMatches[0]['key']])
@@ -787,7 +787,7 @@ protected function addConditionComposition(
787787
array &$conditions,
788788
array &$conditionsParameters
789789
): bool {
790-
if ($this->driver->isSupported(ISupplementalDriver::SUPPORT_MULTI_COLUMN_AS_OR_COND)) {
790+
if ($this->driver->isSupported(Driver::SUPPORT_MULTI_COLUMN_AS_OR_COND)) {
791791
$conditionFragment = '(' . implode(' = ? AND ', $columns) . ' = ?) OR ';
792792
$condition = substr(str_repeat($conditionFragment, count($parameters)), 0, -4);
793793
return $this->addCondition($condition, [Nette\Utils\Arrays::flatten($parameters)], $conditions, $conditionsParameters);

src/compatibility-intf.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Nette Framework (https://nette.org)
5+
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Nette\Database;
11+
12+
if (false) {
13+
/** @deprecated use Nette\Database\Driver */
14+
interface ISupplementalDriver
15+
{
16+
}
17+
} elseif (!interface_exists(ISupplementalDriver::class)) {
18+
class_alias(Driver::class, ISupplementalDriver::class);
19+
}

tests/Database/Reflection.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
declare(strict_types=1);
99

10-
use Nette\Database\ISupplementalDriver;
10+
use Nette\Database\Driver;
1111
use Tester\Assert;
1212

1313
require __DIR__ . '/connect.inc.php'; // create $connection
@@ -20,7 +20,7 @@ $tables = $driver->getTables();
2020
$tables = array_filter($tables, function ($t) { return in_array($t['name'], ['author', 'book', 'book_tag', 'tag'], true); });
2121
usort($tables, function ($a, $b) { return strcmp($a['name'], $b['name']); });
2222

23-
if ($driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)) {
23+
if ($driver->isSupported(Driver::SUPPORT_SCHEMA)) {
2424
Assert::same(
2525
[
2626
['name' => 'author', 'view' => false, 'fullName' => 'public.author'],

tests/Database/Structure.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class StructureTestCase extends TestCase
4646
protected function setUp()
4747
{
4848
parent::setUp();
49-
$this->driver = Mockery::mock(Nette\Database\ISupplementalDriver::class);
49+
$this->driver = Mockery::mock(Nette\Database\Driver::class);
5050
$this->connection = Mockery::mock(Nette\Database\Connection::class);
5151
$this->storage = Mockery::mock(Nette\Caching\IStorage::class);
5252

tests/Database/Structure.schemas.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class StructureSchemasTestCase extends TestCase
4646
protected function setUp()
4747
{
4848
parent::setUp();
49-
$this->driver = Mockery::mock(Nette\Database\ISupplementalDriver::class);
49+
$this->driver = Mockery::mock(Nette\Database\Driver::class);
5050
$this->connection = Mockery::mock(Nette\Database\Connection::class);
5151
$this->storage = Mockery::mock(Nette\Caching\IStorage::class);
5252

tests/Database/Table/SqlBuilder.addAlias().phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
declare(strict_types=1);
99

10-
use Nette\Database\ISupplementalDriver;
10+
use Nette\Database\Driver;
1111
use Nette\Database\Table\SqlBuilder;
1212
use Tester\Assert;
1313

@@ -33,7 +33,7 @@ $driver = $connection->getSupplementalDriver();
3333

3434

3535
test('test duplicated table names throw exception', function () use ($explorer, $driver) {
36-
$authorTable = ($driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA) ? 'public.' : '') . 'author';
36+
$authorTable = ($driver->isSupported(Driver::SUPPORT_SCHEMA) ? 'public.' : '') . 'author';
3737
$sqlBuilder = new SqlBuilderMock($authorTable, $explorer);
3838
$sqlBuilder->addAlias(':book(translator)', 'book1');
3939
$sqlBuilder->addAlias(':book:book_tag', 'book2');
@@ -82,7 +82,7 @@ test('test same table chain with another alias', function () use ($explorer, $dr
8282

8383

8484
test('test nested alias', function () use ($explorer, $driver) {
85-
$sqlBuilder = $driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)
85+
$sqlBuilder = $driver->isSupported(Driver::SUPPORT_SCHEMA)
8686
? new SqlBuilderMock('public.author', $explorer)
8787
: new SqlBuilderMock('author', $explorer);
8888
$sqlBuilder->addAlias(':book(translator)', 'translated_book');
@@ -91,7 +91,7 @@ test('test nested alias', function () use ($explorer, $driver) {
9191
$joins = [];
9292
$sqlBuilder->parseJoins($joins, $query);
9393
$join = $sqlBuilder->buildQueryJoins($joins);
94-
if ($driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)) {
94+
if ($driver->isSupported(Driver::SUPPORT_SCHEMA)) {
9595
Assert::same(
9696
'LEFT JOIN book translated_book ON author.id = translated_book.translator_id ' .
9797
'LEFT JOIN public.book next ON translated_book.next_volume = next.id',

tests/Database/Table/SqlBuilder.addWhere().phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
declare(strict_types=1);
99

1010
use Nette\Database\Conventions\DiscoveredConventions;
11-
use Nette\Database\ISupplementalDriver;
11+
use Nette\Database\Driver;
1212
use Nette\Database\SqlLiteral;
1313
use Nette\Database\Table\SqlBuilder;
1414
use Tester\Assert;
@@ -75,7 +75,7 @@ test('test more ActiveRow as a parameter', function () use ($explorer) {
7575
test('test Selection with parameters as a parameter', function () use ($explorer) {
7676
$sqlBuilder = new SqlBuilder('book', $explorer);
7777
$sqlBuilder->addWhere('id', $explorer->table('book')->having('COUNT(:book_tag.tag_id) >', 1));
78-
$schemaSupported = $explorer->getConnection()->getSupplementalDriver()->isSupported(ISupplementalDriver::SUPPORT_SCHEMA);
78+
$schemaSupported = $explorer->getConnection()->getSupplementalDriver()->isSupported(Driver::SUPPORT_SCHEMA);
7979
Assert::equal(reformat([
8080
'SELECT * FROM [book] WHERE ([id] IN (SELECT [id] FROM [book] LEFT JOIN ' . ($schemaSupported ? '[public].[book_tag] ' : '') . '[book_tag] ON [book].[id] = [book_tag].[book_id] HAVING COUNT([book_tag].[tag_id]) > ?))',
8181
]), $sqlBuilder->buildSelectQuery());

tests/Database/Table/SqlBuilder.parseJoinConditions().phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
declare(strict_types=1);
99

10-
use Nette\Database\ISupplementalDriver;
10+
use Nette\Database\Driver;
1111
use Nette\Database\Table\SqlBuilder;
1212
use Tester\Assert;
1313

@@ -74,7 +74,7 @@ test('', function () use ($explorer, $driver) {
7474
$leftJoinConditions = $sqlBuilder->parseJoinConditions($joins, $sqlBuilder->buildJoinConditions());
7575
$join = $sqlBuilder->buildQueryJoins($joins, $leftJoinConditions);
7676

77-
if ($driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)) {
77+
if ($driver->isSupported(Driver::SUPPORT_SCHEMA)) {
7878
Assert::same(
7979
'LEFT JOIN book ON author.id = book.translator_id AND (book.id > ?) ' .
8080
'LEFT JOIN public.book_tag_alt book_tag_alt ON book.id = book_tag_alt.book_id AND (book_tag_alt.state = ?)',

tests/Database/Table/SqlBuilder.parseJoins().phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
declare(strict_types=1);
99

1010
use Nette\Database\Conventions\DiscoveredConventions;
11-
use Nette\Database\ISupplementalDriver;
11+
use Nette\Database\Driver;
1212
use Nette\Database\Table\SqlBuilder;
1313
use Tester\Assert;
1414

@@ -44,7 +44,7 @@ Assert::same('WHERE priorit.id IS NULL', $query);
4444

4545
$tables = $connection->getSupplementalDriver()->getTables();
4646
if (!in_array($tables[0]['name'], ['npriorities', 'ntopics', 'nusers', 'nusers_ntopics', 'nusers_ntopics_alt'], true)) {
47-
if ($driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)) {
47+
if ($driver->isSupported(Driver::SUPPORT_SCHEMA)) {
4848
Assert::same(
4949
'LEFT JOIN public.nUsers_nTopics nusers_ntopics ON nUsers.nUserId = nusers_ntopics.nUserId ' .
5050
'LEFT JOIN public.nTopics topic ON nusers_ntopics.nTopicId = topic.nTopicId ' .
@@ -87,7 +87,7 @@ Assert::same(
8787
);
8888

8989

90-
$sqlBuilder = $driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)
90+
$sqlBuilder = $driver->isSupported(Driver::SUPPORT_SCHEMA)
9191
? new SqlBuilderMock('public.book', $explorer)
9292
: new SqlBuilderMock('book', $explorer);
9393

@@ -97,7 +97,7 @@ $sqlBuilder->parseJoins($joins, $query);
9797
$join = $sqlBuilder->buildQueryJoins($joins);
9898
Assert::same('WHERE book_ref.translator_id IS NULL AND book_ref_ref.translator_id IS NULL', $query);
9999

100-
if ($driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)) {
100+
if ($driver->isSupported(Driver::SUPPORT_SCHEMA)) {
101101
Assert::same(
102102
'LEFT JOIN public.book book_ref ON book.id = book_ref.next_volume ' .
103103
'LEFT JOIN public.book book_ref_ref ON book_ref.id = book_ref_ref.next_volume',

tests/Database/Table/Table.backjoin.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
declare(strict_types=1);
99

10-
use Nette\Database\ISupplementalDriver;
10+
use Nette\Database\Driver;
1111
use Tester\Assert;
1212

1313
require __DIR__ . '/../connect.inc.php'; // create $connection
@@ -39,7 +39,7 @@ test('', function () use ($explorer) {
3939
test('', function () use ($explorer, $driver) {
4040
$authorsSelection = $explorer->table('author')->where(':book.translator_id IS NOT NULL')->wherePrimary(12);
4141

42-
if ($driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)) {
42+
if ($driver->isSupported(Driver::SUPPORT_SCHEMA)) {
4343
Assert::same(
4444
reformat('SELECT [author].* FROM [author] LEFT JOIN [public].[book] [book] ON [author].[id] = [book].[author_id] WHERE ([book].[translator_id] IS NOT NULL) AND ([author].[id] = ?)'),
4545
$authorsSelection->getSql()

tests/Database/Table/Table.join-condition.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
declare(strict_types=1);
99

10-
use Nette\Database\ISupplementalDriver;
10+
use Nette\Database\Driver;
1111
use Tester\Assert;
1212

1313
require __DIR__ . '/../connect.inc.php'; // create $connection
1414

1515
Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverName}-nette_test1.sql");
1616
$driver = $connection->getSupplementalDriver();
1717
test('', function () use ($explorer, $driver) {
18-
$schema = $driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)
18+
$schema = $driver->isSupported(Driver::SUPPORT_SCHEMA)
1919
? '[public].'
2020
: '';
2121
$sql = $explorer->table('book')->joinWhere('translator', 'translator.name', 'Geek')->select('book.*')->getSql();
@@ -34,7 +34,7 @@ test('', function () use ($explorer, $driver) {
3434
->where('tag.name', 'PHP')
3535
->group('tag.name')
3636
->getSql();
37-
if ($driver->isSupported(ISupplementalDriver::SUPPORT_SCHEMA)) {
37+
if ($driver->isSupported(Driver::SUPPORT_SCHEMA)) {
3838
Assert::same(
3939
reformat(
4040
'SELECT [tag].[name], COUNT([book].[id]) AS [count_of_next_volume_written_by_younger_author] FROM [tag] ' .

0 commit comments

Comments
 (0)