Skip to content

Commit b85becd

Browse files
committed
fix: almost all deprecations
1 parent ab808fe commit b85becd

14 files changed

+149
-233
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@
2222

2323
namespace Crate\DBAL\Driver\PDOCrate;
2424

25-
use Crate\PDO\PDO;
25+
use Crate\PDO\PDOCrateDB;
2626
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
2727

28-
class PDOConnection extends PDO implements ServerInfoAwareConnection
28+
class PDOConnection extends PDOCrateDB implements ServerInfoAwareConnection
2929
{
3030
/**
3131
* @param string $dsn
32-
* @param string $user
33-
* @param string $password
32+
* @param string|null $user
33+
* @param string|null $password
3434
* @param array $options
3535
*/
3636
public function __construct($dsn, $user = null, $password = null, array $options = null)
3737
{
3838
parent::__construct($dsn, $user, $password, $options);
39-
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, CrateStatement::class);
40-
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
39+
$this->setAttribute(PDOCrateDB::ATTR_STATEMENT_CLASS, CrateStatement::class);
40+
$this->setAttribute(PDOCrateDB::ATTR_ERRMODE, PDOCrateDB::ERRMODE_EXCEPTION);
4141
}
4242

4343
/**

src/Crate/DBAL/Platforms/CratePlatform.php

+26-41
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
use Crate\DBAL\Types\MapType;
2525
use Crate\DBAL\Types\TimestampType;
26-
use Doctrine\DBAL\DBALException;
26+
use Doctrine\DBAL\Exception;
2727
use Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs;
2828
use Doctrine\DBAL\Event\SchemaCreateTableEventArgs;
2929
use Doctrine\DBAL\Events;
@@ -76,7 +76,7 @@ public function getSubstringExpression($value, $from = 0, $length = null)
7676
*/
7777
public function getNowExpression()
7878
{
79-
throw DBALException::notSupported(__METHOD__);
79+
throw Exception::notSupported(__METHOD__);
8080
}
8181

8282
/**
@@ -92,7 +92,7 @@ public function getRegexpExpression()
9292
*/
9393
public function getDateDiffExpression($date1, $date2)
9494
{
95-
throw DBALException::notSupported(__METHOD__);
95+
throw Exception::notSupported(__METHOD__);
9696
}
9797

9898
/**
@@ -146,14 +146,6 @@ public function supportsForeignKeyConstraints()
146146
return false;
147147
}
148148

149-
/**
150-
* {@inheritDoc}
151-
*/
152-
public function supportsForeignKeyOnUpdate()
153-
{
154-
return false;
155-
}
156-
157149
/**
158150
* {@inheritDoc}
159151
*/
@@ -162,20 +154,12 @@ public function supportsViews()
162154
return false;
163155
}
164156

165-
/**
166-
* {@inheritDoc}
167-
*/
168-
public function prefersSequences()
169-
{
170-
return false;
171-
}
172-
173157
/**
174158
* {@inheritDoc}
175159
*/
176160
public function getListDatabasesSQL()
177161
{
178-
throw DBALException::notSupported(__METHOD__);
162+
throw Exception::notSupported(__METHOD__);
179163
}
180164

181165
/**
@@ -270,23 +254,23 @@ public function getAlterTableSQL(TableDiff $diff)
270254
}
271255

272256
if (count($diff->removedColumns) > 0) {
273-
throw DBALException::notSupported("Alter Table: drop columns");
257+
throw Exception::notSupported("Alter Table: drop columns");
274258
}
275259
if (count($diff->changedColumns) > 0) {
276-
throw DBALException::notSupported("Alter Table: change column options");
260+
throw Exception::notSupported("Alter Table: change column options");
277261
}
278262
if (count($diff->renamedColumns) > 0) {
279-
throw DBALException::notSupported("Alter Table: rename columns");
263+
throw Exception::notSupported("Alter Table: rename columns");
280264
}
281265

282266
$tableSql = array();
283267

284268
if (!$this->onSchemaAlterTable($diff, $tableSql)) {
285269
if ($diff->newName !== false) {
286-
throw DBALException::notSupported("Alter Table: rename table");
270+
throw Exception::notSupported("Alter Table: rename table");
287271
}
288272

289-
$sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySQL($diff), $commentsSQL);
273+
$sql = array_merge($sql, $this->getPreAlterTableIndexForeignKeySQL($diff), $this->getPostAlterTableIndexForeignKeySQL($diff), $commentsSQL);
290274
}
291275

292276
return array_merge($sql, $tableSql, $columnSql);
@@ -469,6 +453,7 @@ public function getName()
469453
*/
470454
public function getSQLResultCasing($column)
471455
{
456+
472457
return strtolower($column);
473458
}
474459

@@ -509,15 +494,15 @@ public function getTimeFormatString()
509494
*/
510495
public function getTruncateTableSQL($tableName, $cascade = false)
511496
{
512-
throw DBALException::notSupported(__METHOD__);
497+
throw Exception::notSupported(__METHOD__);
513498
}
514499

515500
/**
516501
* {@inheritDoc}
517502
*/
518503
public function getReadLockSQL()
519504
{
520-
throw DBALException::notSupported(__METHOD__);
505+
throw Exception::notSupported(__METHOD__);
521506
}
522507

523508
/**
@@ -575,7 +560,7 @@ protected function getReservedKeywordsClass()
575560
*/
576561
public function getBlobTypeDeclarationSQL(array $field)
577562
{
578-
throw DBALException::notSupported(__METHOD__);
563+
throw Exception::notSupported(__METHOD__);
579564
}
580565

581566
/**
@@ -596,7 +581,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE
596581
}
597582

598583
if (count($table->getColumns()) === 0) {
599-
throw DBALException::noColumnsSpecifiedForTable($table->getName());
584+
throw Exception::noColumnsSpecifiedForTable($table->getName());
600585
}
601586

602587
$tableName = $table->getQuotedName($this);
@@ -615,7 +600,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE
615600
}, $index->getColumns());
616601
$options['primary_index'] = $index;
617602
} elseif ($index->isUnique()) {
618-
throw DBALException::notSupported(
603+
throw Exception::notSupported(
619604
"Unique constraints are not supported. Use `primary key` instead"
620605
);
621606
} else {
@@ -685,9 +670,9 @@ protected function _getCreateTableSQL($name, array $columns, array $options = ar
685670
$columnListSql .= ', ' . $this->getIndexDeclarationSQL($index, $definition);
686671
}
687672
}
688-
673+
689674
if (isset($options['foreignKeys'])) {
690-
throw DBALException::notSupported("Create Table: foreign keys");
675+
throw Exception::notSupported("Create Table: foreign keys");
691676
}
692677

693678
$query = 'CREATE TABLE ' . $name . ' (' . $columnListSql . ')';
@@ -774,15 +759,15 @@ private function buildPartitionOptions(array $options)
774759

775760
/**
776761
* @param \Doctrine\DBAL\Schema\Column $column The name of the table.
777-
* @param array List of primary key column names
762+
* @param array $primaries List of primary key column names
778763
*
779764
* @return array The column data as associative array.
780-
* @throws DBALException
765+
* @throws Exception
781766
*/
782767
public static function prepareColumnData(AbstractPlatform $platform, $column, $primaries = array())
783768
{
784769
if ($column->hasCustomSchemaOption("unique") ? $column->getCustomSchemaOption("unique") : false) {
785-
throw DBALException::notSupported("Unique constraints are not supported. Use `primary key` instead");
770+
throw Exception::notSupported("Unique constraints are not supported. Use `primary key` instead");
786771
}
787772

788773
$columnData = array();
@@ -819,31 +804,31 @@ public static function prepareColumnData(AbstractPlatform $platform, $column, $p
819804
*/
820805
public function getCreateDatabaseSQL($database)
821806
{
822-
throw DBALException::notSupported(__METHOD__);
807+
throw Exception::notSupported(__METHOD__);
823808
}
824809

825810
/**
826811
* {@inheritDoc}
827812
*/
828813
public function getDropDatabaseSQL($database)
829814
{
830-
throw DBALException::notSupported(__METHOD__);
815+
throw Exception::notSupported(__METHOD__);
831816
}
832-
817+
833818
/**
834819
* {@inheritDoc}
835820
*/
836821
public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table)
837822
{
838-
throw DBALException::notSupported(__METHOD__);
823+
throw Exception::notSupported(__METHOD__);
839824
}
840-
825+
841826
/**
842827
* {@inheritDoc}
843828
*/
844829
public function getGuidTypeDeclarationSQL(array $field)
845830
{
846-
throw DBALException::notSupported(__METHOD__);
831+
throw Exception::notSupported(__METHOD__);
847832
}
848833

849834
/**

src/Crate/DBAL/Schema/CrateSchemaManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function listTableDetails($tableName) : Table
122122
$indexes = $this->listTableIndexes($tableName);
123123
$options = [];
124124

125-
$s = $this->_conn->fetchAssoc($this->_platform->getTableOptionsSQL($tableName));
125+
$s = $this->_conn->fetchAssociative($this->_platform->getTableOptionsSQL($tableName));
126126

127127
$options['sharding_routing_column'] = $s['clustered_by'];
128128
$options['sharding_num_shards'] = $s['number_of_shards'];

src/Crate/DBAL/Types/ArrayType.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222

2323
namespace Crate\DBAL\Types;
2424

25-
use Crate\PDO\PDO;
25+
use Crate\PDO\PDOCrateDB;
2626
use Doctrine\DBAL\Types\Type;
2727
use Doctrine\DBAL\Platforms\AbstractPlatform;
28+
use Doctrine\DBAL\Types\Types;
2829

2930
/**
3031
* Type that maps a PHP sequential array to an array SQL type.
@@ -53,7 +54,7 @@ public function getName()
5354
*/
5455
public function getBindingType()
5556
{
56-
return PDO::PARAM_ARRAY;
57+
return PDOCrateDB::PARAM_ARRAY;
5758
}
5859

5960
public function convertToDatabaseValue($value, AbstractPlatform $platform)
@@ -96,7 +97,7 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla
9697
*/
9798
public function getArrayTypeDeclarationSQL(AbstractPlatform $platform, array $field, array $options)
9899
{
99-
$type = array_key_exists('type', $options) ? $options['type'] : Type::STRING;
100+
$type = array_key_exists('type', $options) ? $options['type'] : Types::STRING;
100101
return 'ARRAY ( ' . Type::getType($type)->getSQLDeclaration($field, $platform) . ' )';
101102
}
102103
}

src/Crate/DBAL/Types/MapType.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
namespace Crate\DBAL\Types;
2424

2525
use Crate\DBAL\Platforms\CratePlatform;
26-
use Crate\PDO\PDO;
26+
use Crate\PDO\PDOCrateDB;
2727
use Doctrine\DBAL\Types\Type;
2828
use Doctrine\DBAL\Platforms\AbstractPlatform;
2929

@@ -59,7 +59,7 @@ public function getName()
5959
*/
6060
public function getBindingType()
6161
{
62-
return PDO::PARAM_OBJECT;
62+
return PDOCrateDB::PARAM_OBJECT;
6363
}
6464

6565
public function convertToDatabaseValue($value, AbstractPlatform $platform)

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*/
2222
namespace Crate\Test\DBAL\Functional;
2323

24+
use Crate\PDO\PDOCrateDB;
2425
use Crate\Test\DBAL\DBALFunctionalTestCase;
25-
use Crate\PDO\PDO;
2626

2727
class ConnectionTestCase extends DBALFunctionalTestCase
2828
{
@@ -49,9 +49,9 @@ public function testBasicAuthConnection()
4949
'password' => $auth[1],
5050
);
5151
$conn = \Doctrine\DBAL\DriverManager::getConnection($params);
52-
$this->assertEquals($auth[0], $conn->getUsername());
53-
$this->assertEquals($auth[1], $conn->getPassword());
54-
$auth_attr = $conn->getWrappedConnection()->getAttribute(PDO::CRATE_ATTR_HTTP_BASIC_AUTH);
52+
$this->assertEquals($auth[0], $conn->getParams()['username']);
53+
$this->assertEquals($auth[1], $conn->getParams()['password']);
54+
$auth_attr = $conn->getWrappedConnection()->getAttribute(PDOCrateDB::CRATE_ATTR_HTTP_BASIC_AUTH);
5555
$this->assertEquals($auth_attr, $auth);
5656
}
5757

@@ -79,10 +79,10 @@ public function testConnect()
7979
{
8080
$this->assertTrue($this->_conn->connect());
8181

82-
$stmt = $this->_conn->query('select * from sys.cluster');
82+
$stmt = $this->_conn->executeQuery('select * from sys.cluster');
8383
$this->assertEquals(1, $stmt->rowCount());
8484

85-
$row = $stmt->fetch();
85+
$row = $stmt->fetchOne();
8686
$this->assertEquals('crate', $row['name']);
8787
}
8888

0 commit comments

Comments
 (0)