]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(db): Promote the use of `getDatabaseProvider` to reduce the impage of removed...
authorJoas Schilling <coding@schilljs.com>
Mon, 1 Jul 2024 14:59:47 +0000 (16:59 +0200)
committerJoas Schilling <coding@schilljs.com>
Fri, 19 Jul 2024 09:21:14 +0000 (11:21 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
19 files changed:
apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
apps/settings/tests/SetupChecks/SupportedDatabaseTest.php
apps/user_ldap/lib/Mapping/AbstractMapping.php
core/Command/Db/ConvertFilecacheBigInt.php
core/Command/Db/ConvertMysqlToMB4.php
core/Migrations/Version13000Date20170718121200.php
lib/private/AllConfig.php
lib/private/BackgroundJob/JobList.php
lib/private/DB/Connection.php
lib/private/DB/ConnectionAdapter.php
lib/private/DB/MigrationService.php
lib/private/DB/QueryBuilder/QueryBuilder.php
lib/private/Repair/Collation.php
lib/public/IDBConnection.php
tests/lib/DB/MigrationsTest.php
tests/lib/DB/MigratorTest.php
tests/lib/DB/OCPostgreSqlPlatformTest.php
tests/lib/Files/Cache/CacheTest.php
tests/lib/Repair/RepairCollationTest.php

index cbce847a298c2f7e060e084b6a6499918fadc40f..c7f57dcb11718a22c68cae772ec7246cbfd66bfa 100644 (file)
@@ -5,7 +5,6 @@
  */
 namespace OCA\DAV\Migration;
 
-use Doctrine\DBAL\Platforms\OraclePlatform;
 use OCA\DAV\CalDAV\CalDavBackend;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IDBConnection;
@@ -75,7 +74,7 @@ class CalDAVRemoveEmptyValue implements IRepairStep {
        }
 
        protected function getInvalidObjects($pattern) {
-               if ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
+               if ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
                        $rows = [];
                        $chunkSize = 500;
                        $query = $this->db->getQueryBuilder();
index 2492379b557ca468c06a1c055b736599bb759ee6..0ba1621c5febb800ef8877f470c5b47ceaa5970f 100644 (file)
@@ -8,7 +8,6 @@ declare(strict_types=1);
  */
 namespace OCA\Settings\Tests;
 
-use Doctrine\DBAL\Platforms\SqlitePlatform;
 use OCA\Settings\SetupChecks\SupportedDatabase;
 use OCP\IDBConnection;
 use OCP\IL10N;
@@ -41,8 +40,7 @@ class SupportedDatabaseTest extends TestCase {
        }
 
        public function testPass(): void {
-               $platform = $this->connection->getDatabasePlatform();
-               if ($platform instanceof SqlitePlatform) {
+               if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) {
                        /** SQlite always gets a warning */
                        $this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity());
                } else {
index c243731eaf7a30779408457be6cd4e39cd24b063..79d23b8d6187df5ee82ff297d2f86858d95a9100 100644 (file)
@@ -8,9 +8,9 @@
 namespace OCA\User_LDAP\Mapping;
 
 use Doctrine\DBAL\Exception;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
 use OCP\DB\IPreparedStatement;
 use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IDBConnection;
 use Psr\Log\LoggerInterface;
 
 /**
@@ -216,7 +216,7 @@ abstract class AbstractMapping {
        public function getListOfIdsByDn(array $fdns): array {
                $totalDBParamLimit = 65000;
                $sliceSize = 1000;
-               $maxSlices = $this->dbc->getDatabasePlatform() instanceof SqlitePlatform ? 9 : $totalDBParamLimit / $sliceSize;
+               $maxSlices = $this->dbc->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE ? 9 : $totalDBParamLimit / $sliceSize;
                $results = [];
 
                $slice = 1;
index 5f3e790e9ceb85d6611f75d720bd413634fddfa0..d16e6d302312f1a252098d32ecd590a8afe207d9 100644 (file)
@@ -5,11 +5,11 @@
  */
 namespace OC\Core\Command\Db;
 
-use Doctrine\DBAL\Platforms\SqlitePlatform;
 use Doctrine\DBAL\Types\Type;
 use OC\DB\Connection;
 use OC\DB\SchemaWrapper;
 use OCP\DB\Types;
+use OCP\IDBConnection;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
@@ -53,7 +53,7 @@ class ConvertFilecacheBigInt extends Command {
 
        protected function execute(InputInterface $input, OutputInterface $output): int {
                $schema = new SchemaWrapper($this->connection);
-               $isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform;
+               $isSqlite = $this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE;
                $updates = [];
 
                $tables = static::getColumnsByTable();
index 679cdd5f616112a94823d66230ff3795c16096c4..618e15de3f45a64d8c4f697e5bcf2781a27c7afa 100644 (file)
@@ -5,7 +5,6 @@
  */
 namespace OC\Core\Command\Db;
 
-use Doctrine\DBAL\Platforms\MySQLPlatform;
 use OC\DB\MySqlTools;
 use OC\Migration\ConsoleOutput;
 use OC\Repair\Collation;
@@ -34,7 +33,7 @@ class ConvertMysqlToMB4 extends Command {
        }
 
        protected function execute(InputInterface $input, OutputInterface $output): int {
-               if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
+               if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) {
                        $output->writeln("This command is only valid for MySQL/MariaDB databases.");
                        return 1;
                }
index c485e025c37096c6aae6950c2039ed9669578a9d..3985bdaeb57e6c1e951e37abcaf31216f2c6f484 100644 (file)
@@ -5,7 +5,6 @@
  */
 namespace OC\Core\Migrations;
 
-use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
 use OCP\DB\ISchemaWrapper;
 use OCP\DB\Types;
 use OCP\IDBConnection;
@@ -238,7 +237,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
                        $table->addIndex(['name'], 'fs_name_hash');
                        $table->addIndex(['mtime'], 'fs_mtime');
                        $table->addIndex(['size'], 'fs_size');
-                       if (!$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) {
+                       if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_POSTGRES) {
                                $table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]);
                        }
                }
index d05fe440202dd6133d67fa932a68170745f4e2eb..58eee772fbf91a5ab2650b391d0e18f22022bc11 100644 (file)
@@ -6,7 +6,6 @@
  */
 namespace OC;
 
-use Doctrine\DBAL\Platforms\OraclePlatform;
 use OCP\Cache\CappedMemoryCache;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IConfig;
@@ -470,7 +469,7 @@ class AllConfig implements IConfig {
                $this->fixDIInit();
 
                $qb = $this->connection->getQueryBuilder();
-               $configValueColumn = ($this->connection->getDatabasePlatform() instanceof OraclePlatform)
+               $configValueColumn = ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE)
                        ? $qb->expr()->castColumn('configvalue', IQueryBuilder::PARAM_STR)
                        : 'configvalue';
                $result = $qb->select('userid')
@@ -509,7 +508,7 @@ class AllConfig implements IConfig {
                }
 
                $qb = $this->connection->getQueryBuilder();
-               $configValueColumn = ($this->connection->getDatabasePlatform() instanceof OraclePlatform)
+               $configValueColumn = ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE)
                        ? $qb->expr()->castColumn('configvalue', IQueryBuilder::PARAM_STR)
                        : 'configvalue';
 
index 201263320e3789bdc1d06337573829c6e006016b..5aaf14d62e75bb3b62258efeaf7fac777914e8b8 100644 (file)
@@ -7,7 +7,6 @@
  */
 namespace OC\BackgroundJob;
 
-use Doctrine\DBAL\Platforms\MySQLPlatform;
 use OCP\AppFramework\QueryException;
 use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\AutoloadNotAllowedException;
@@ -98,7 +97,7 @@ class JobList implements IJobList {
 
                // Add galera safe delete chunking if using mysql
                // Stops us hitting wsrep_max_ws_rows when large row counts are deleted
-               if ($this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
+               if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL) {
                        // Then use chunked delete
                        $max = IQueryBuilder::MAX_ROW_DELETION;
 
index c24754a52bd3bd880d03d09fa9e8c0153d1e945a..7aa3a020113c78667b6090b700c8935ea6661e11 100644 (file)
@@ -17,6 +17,7 @@ use Doctrine\DBAL\Exception;
 use Doctrine\DBAL\Exception\ConnectionLost;
 use Doctrine\DBAL\Platforms\MySQLPlatform;
 use Doctrine\DBAL\Platforms\OraclePlatform;
+use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
 use Doctrine\DBAL\Platforms\SqlitePlatform;
 use Doctrine\DBAL\Result;
 use Doctrine\DBAL\Schema\Schema;
@@ -25,6 +26,7 @@ use OC\DB\QueryBuilder\QueryBuilder;
 use OC\SystemConfig;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\Diagnostics\IEventLogger;
+use OCP\IDBConnection;
 use OCP\IRequestId;
 use OCP\PreConditionNotMetException;
 use OCP\Profiler\IProfiler;
@@ -729,4 +731,22 @@ class Connection extends PrimaryReadReplicaConnection {
        private function getConnectionName(): string {
                return $this->isConnectedToPrimary() ? 'primary' : 'replica';
        }
+
+       /**
+        * @return IDBConnection::PLATFORM_MYSQL|IDBConnection::PLATFORM_ORACLE|IDBConnection::PLATFORM_POSTGRES|IDBConnection::PLATFORM_SQLITE
+        */
+       public function getDatabaseProvider(): string {
+               $platform = $this->getDatabasePlatform();
+               if ($platform instanceof MySQLPlatform) {
+                       return IDBConnection::PLATFORM_MYSQL;
+               } elseif ($platform instanceof OraclePlatform) {
+                       return IDBConnection::PLATFORM_ORACLE;
+               } elseif ($platform instanceof PostgreSQLPlatform) {
+                       return IDBConnection::PLATFORM_POSTGRES;
+               } elseif ($platform instanceof SqlitePlatform) {
+                       return IDBConnection::PLATFORM_SQLITE;
+               } else {
+                       throw new \Exception('Database ' . $platform::class . ' not supported');
+               }
+       }
 }
index 86a901a7de33d070697779e27434d85849597476..8a919696eaa2f8a211d41774dad1d4e7fc6db211 100644 (file)
@@ -10,10 +10,6 @@ namespace OC\DB;
 
 use Doctrine\DBAL\Exception;
 use Doctrine\DBAL\Platforms\AbstractPlatform;
-use Doctrine\DBAL\Platforms\MySQLPlatform;
-use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
 use Doctrine\DBAL\Schema\Schema;
 use OC\DB\Exceptions\DbalException;
 use OCP\DB\IPreparedStatement;
@@ -230,18 +226,10 @@ class ConnectionAdapter implements IDBConnection {
                return $this->inner;
        }
 
+       /**
+        * @return self::PLATFORM_MYSQL|self::PLATFORM_ORACLE|self::PLATFORM_POSTGRES|self::PLATFORM_SQLITE
+        */
        public function getDatabaseProvider(): string {
-               $platform = $this->inner->getDatabasePlatform();
-               if ($platform instanceof MySQLPlatform) {
-                       return IDBConnection::PLATFORM_MYSQL;
-               } elseif ($platform instanceof OraclePlatform) {
-                       return IDBConnection::PLATFORM_ORACLE;
-               } elseif ($platform instanceof PostgreSQLPlatform) {
-                       return IDBConnection::PLATFORM_POSTGRES;
-               } elseif ($platform instanceof SqlitePlatform) {
-                       return IDBConnection::PLATFORM_SQLITE;
-               } else {
-                       throw new \Exception('Database ' . $platform::class . ' not supported');
-               }
+               return $this->inner->getDatabaseProvider();
        }
 }
index 19d1b2407369b4b3b24626515129633824f4541b..0a3b0d1dcc7733cf6514175f5d5def4e08686e0d 100644 (file)
@@ -6,20 +6,19 @@
  */
 namespace OC\DB;
 
-use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
 use Doctrine\DBAL\Schema\Index;
 use Doctrine\DBAL\Schema\Schema;
 use Doctrine\DBAL\Schema\SchemaException;
 use Doctrine\DBAL\Schema\Sequence;
 use Doctrine\DBAL\Schema\Table;
-use Doctrine\DBAL\Types\Types;
 use OC\App\InfoParser;
 use OC\IntegrityCheck\Helpers\AppLocator;
 use OC\Migration\SimpleOutput;
 use OCP\AppFramework\App;
 use OCP\AppFramework\QueryException;
 use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
+use OCP\IDBConnection;
 use OCP\Migration\IMigrationStep;
 use OCP\Migration\IOutput;
 use OCP\Server;
@@ -599,7 +598,7 @@ class MigrationService {
                                $indexName = strtolower($primaryKey->getName());
                                $isUsingDefaultName = $indexName === 'primary';
 
-                               if ($this->connection->getDatabasePlatform() instanceof PostgreSQL94Platform) {
+                               if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_POSTGRES) {
                                        $defaultName = $table->getName() . '_pkey';
                                        $isUsingDefaultName = strtolower($defaultName) === $indexName;
 
@@ -609,7 +608,7 @@ class MigrationService {
                                                        return $sequence->getName() !== $sequenceName;
                                                });
                                        }
-                               } elseif ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
+                               } elseif ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
                                        $defaultName = $table->getName() . '_seq';
                                        $isUsingDefaultName = strtolower($defaultName) === $indexName;
                                }
index 81d8b1e7a1ae097eb2dfbabce27dcf087550e254..529b88199e692e2935f5f4a1f607a910ec7cf6a8 100644 (file)
@@ -7,14 +7,9 @@
  */
 namespace OC\DB\QueryBuilder;
 
-use Doctrine\DBAL\Platforms\MySQLPlatform;
-use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
 use Doctrine\DBAL\Query\QueryException;
 use OC\DB\ConnectionAdapter;
 use OC\DB\Exceptions\DbalException;
-use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder;
 use OC\DB\QueryBuilder\ExpressionBuilder\MySqlExpressionBuilder;
 use OC\DB\QueryBuilder\ExpressionBuilder\OCIExpressionBuilder;
 use OC\DB\QueryBuilder\ExpressionBuilder\PgSqlExpressionBuilder;
@@ -96,20 +91,12 @@ class QueryBuilder implements IQueryBuilder {
         * @return \OCP\DB\QueryBuilder\IExpressionBuilder
         */
        public function expr() {
-               if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
-                       return new OCIExpressionBuilder($this->connection, $this);
-               }
-               if ($this->connection->getDatabasePlatform() instanceof PostgreSQL94Platform) {
-                       return new PgSqlExpressionBuilder($this->connection, $this);
-               }
-               if ($this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
-                       return new MySqlExpressionBuilder($this->connection, $this);
-               }
-               if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
-                       return new SqliteExpressionBuilder($this->connection, $this);
-               }
-
-               return new ExpressionBuilder($this->connection, $this);
+               return match($this->connection->getDatabaseProvider()) {
+                       IDBConnection::PLATFORM_ORACLE => new OCIExpressionBuilder($this->connection, $this),
+                       IDBConnection::PLATFORM_POSTGRES => new PgSqlExpressionBuilder($this->connection, $this),
+                       IDBConnection::PLATFORM_MYSQL => new MySqlExpressionBuilder($this->connection, $this),
+                       IDBConnection::PLATFORM_SQLITE => new SqliteExpressionBuilder($this->connection, $this),
+               };
        }
 
        /**
@@ -129,17 +116,12 @@ class QueryBuilder implements IQueryBuilder {
         * @return \OCP\DB\QueryBuilder\IFunctionBuilder
         */
        public function func() {
-               if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
-                       return new OCIFunctionBuilder($this->connection, $this, $this->helper);
-               }
-               if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
-                       return new SqliteFunctionBuilder($this->connection, $this, $this->helper);
-               }
-               if ($this->connection->getDatabasePlatform() instanceof PostgreSQL94Platform) {
-                       return new PgSqlFunctionBuilder($this->connection, $this, $this->helper);
-               }
-
-               return new FunctionBuilder($this->connection, $this, $this->helper);
+               return match($this->connection->getDatabaseProvider()) {
+                       IDBConnection::PLATFORM_ORACLE => new OCIFunctionBuilder($this->connection, $this, $this->helper),
+                       IDBConnection::PLATFORM_POSTGRES => new PgSqlFunctionBuilder($this->connection, $this, $this->helper),
+                       IDBConnection::PLATFORM_MYSQL => new FunctionBuilder($this->connection, $this, $this->helper),
+                       IDBConnection::PLATFORM_SQLITE => new SqliteFunctionBuilder($this->connection, $this, $this->helper),
+               };
        }
 
        /**
index 0affb3b1ca98057382b0c6f2fef91f4f64f4f70b..a01a684151b08d7d8b13435116c25b9c116db323 100644 (file)
@@ -8,7 +8,6 @@
 namespace OC\Repair;
 
 use Doctrine\DBAL\Exception\DriverException;
-use Doctrine\DBAL\Platforms\MySQLPlatform;
 use OCP\IConfig;
 use OCP\IDBConnection;
 use OCP\Migration\IOutput;
@@ -50,7 +49,7 @@ class Collation implements IRepairStep {
         * Fix mime types
         */
        public function run(IOutput $output) {
-               if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
+               if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) {
                        $output->info('Not a mysql database -> nothing to do');
                        return;
                }
index a5df85896e2a12fc9bbc43dd51621d7640e0e75d..09bd1a564cd46035c70efd4fb6e85ebbfdda35fb 100644 (file)
@@ -278,6 +278,7 @@ interface IDBConnection {
         *
         * @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
         * @since 8.0.0
+        * @deprecated 30.0.0 Please use {@see self::getDatabaseProvider()} and compare to self::PLATFORM_* constants
         */
        public function getDatabasePlatform();
 
@@ -341,7 +342,7 @@ interface IDBConnection {
         * Returns the database provider name
         * @link https://github.com/nextcloud/server/issues/30877
         * @since 28.0.0
-        * @return IDBConnection::PLATFORM_*
+        * @return self::PLATFORM_MYSQL|self::PLATFORM_ORACLE|self::PLATFORM_POSTGRES|self::PLATFORM_SQLITE
         */
        public function getDatabaseProvider(): string;
 }
index 6cd489258bffe28d28e29f98c47361d746a35636..2bdd705ff5d45e40289586dcd168f18b520acafb 100644 (file)
@@ -8,8 +8,6 @@
 
 namespace Test\DB;
 
-use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
 use Doctrine\DBAL\Schema\Column;
 use Doctrine\DBAL\Schema\ForeignKeyConstraint;
 use Doctrine\DBAL\Schema\Index;
@@ -326,9 +324,9 @@ class MigrationsTest extends \Test\TestCase {
 
        public function testEnsureOracleConstraintsValidWithPrimaryKeyDefault() {
                $defaultName = 'PRIMARY';
-               if ($this->db->getDatabasePlatform() instanceof PostgreSqlPlatform) {
+               if ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_POSTGRES) {
                        $defaultName = \str_repeat('a', 26) . '_' . \str_repeat('b', 30) . '_seq';
-               } elseif ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
+               } elseif ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
                        $defaultName = \str_repeat('a', 26) . '_seq';
                }
 
@@ -407,9 +405,9 @@ class MigrationsTest extends \Test\TestCase {
                $this->expectException(\InvalidArgumentException::class);
 
                $defaultName = 'PRIMARY';
-               if ($this->db->getDatabasePlatform() instanceof PostgreSqlPlatform) {
+               if ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_POSTGRES) {
                        $defaultName = \str_repeat('a', 27) . '_' . \str_repeat('b', 30) . '_seq';
-               } elseif ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
+               } elseif ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
                        $defaultName = \str_repeat('a', 27) . '_seq';
                }
 
index eaa6540b93bd65acc44fa8a8603588aaaf753562..d12b70725ed39960bfcd89606ff75d17bdacd442 100644 (file)
@@ -10,8 +10,6 @@ namespace Test\DB;
 
 use Doctrine\DBAL\Exception;
 use Doctrine\DBAL\ParameterType;
-use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
 use Doctrine\DBAL\Schema\Schema;
 use Doctrine\DBAL\Schema\SchemaConfig;
 use OC\DB\Migrator;
@@ -19,7 +17,7 @@ use OC\DB\OracleMigrator;
 use OC\DB\SQLiteMigrator;
 use OCP\DB\Types;
 use OCP\IConfig;
-use OCP\Security\ISecureRandom;
+use OCP\IDBConnection;
 
 /**
  * Class MigratorTest
@@ -56,12 +54,10 @@ class MigratorTest extends \Test\TestCase {
        }
 
        private function getMigrator(): Migrator {
-               $platform = $this->connection->getDatabasePlatform();
-               $random = \OC::$server->get(ISecureRandom::class);
                $dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
-               if ($platform instanceof SqlitePlatform) {
+               if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) {
                        return new SQLiteMigrator($this->connection, $this->config, $dispatcher);
-               } elseif ($platform instanceof OraclePlatform) {
+               } elseif ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
                        return new OracleMigrator($this->connection, $this->config, $dispatcher);
                }
                return new Migrator($this->connection, $this->config, $dispatcher);
@@ -300,7 +296,7 @@ class MigratorTest extends \Test\TestCase {
                $migrator = $this->getMigrator();
                $migrator->migrate($startSchema);
 
-               if ($oracleThrows && $this->connection->getDatabasePlatform() instanceof OraclePlatform) {
+               if ($oracleThrows && $this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
                        // Oracle can not store false|empty string in notnull columns
                        $this->expectException(\Doctrine\DBAL\Exception\NotNullConstraintViolationException::class);
                }
index 4f83e866a7c510803ea8b34693de8b1f54756aea..3ed420df501db9d38d5eb73e70c2173991aa89c9 100644 (file)
@@ -7,7 +7,7 @@
 
 namespace Test\DB;
 
-use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
+use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
 use Doctrine\DBAL\Schema\Comparator;
 use Doctrine\DBAL\Schema\Schema;
 use Doctrine\DBAL\Types\Types;
@@ -24,7 +24,7 @@ use Doctrine\DBAL\Types\Types;
  */
 class OCPostgreSqlPlatformTest extends \Test\TestCase {
        public function testAlterBigint() {
-               $platform = new PostgreSQL100Platform();
+               $platform = new PostgreSQLPlatform();
                $sourceSchema = new Schema();
                $targetSchema = new Schema();
 
index faecbf54491c05a3ac5d980e151b371a8a1d7159..a36607eb9659e0ccdb738b7569b63b27a4eddd5c 100644 (file)
@@ -7,12 +7,12 @@
 
 namespace Test\Files\Cache;
 
-use Doctrine\DBAL\Platforms\MySqlPlatform;
 use OC\Files\Cache\Cache;
 use OC\Files\Search\SearchComparison;
 use OC\Files\Search\SearchQuery;
 use OCP\EventDispatcher\IEventDispatcher;
 use OCP\Files\Search\ISearchComparison;
+use OCP\IDBConnection;
 use OCP\IUser;
 
 class LongId extends \OC\Files\Storage\Temporary {
@@ -142,7 +142,7 @@ class CacheTest extends \Test\TestCase {
                if (strpos($folder, 'F09F9890')) {
                        // 4 byte UTF doesn't work on mysql
                        $params = \OC::$server->get(\OC\DB\Connection::class)->getParams();
-                       if (\OC::$server->getDatabaseConnection()->getDatabasePlatform() instanceof MySqlPlatform && $params['charset'] !== 'utf8mb4') {
+                       if (\OC::$server->getDatabaseConnection()->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL && $params['charset'] !== 'utf8mb4') {
                                $this->markTestSkipped('MySQL doesn\'t support 4 byte UTF-8');
                        }
                }
index 5f5e0737f77bd17ab6dd36d9d878db22253f0a22..6d3946b2a85b8fb84826acb42876c2380ab1d433 100644 (file)
@@ -7,7 +7,6 @@
 
 namespace Test\Repair;
 
-use Doctrine\DBAL\Platforms\MySqlPlatform;
 use OC\Repair\Collation;
 use OCP\IDBConnection;
 use OCP\Migration\IOutput;
@@ -61,7 +60,7 @@ class RepairCollationTest extends TestCase {
                $this->connection = \OC::$server->get(IDBConnection::class);
                $this->logger = $this->createMock(LoggerInterface::class);
                $this->config = \OC::$server->getConfig();
-               if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
+               if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) {
                        $this->markTestSkipped("Test only relevant on MySql");
                }