protected function hasValidTransactionIsolationLevel(): bool { | protected function hasValidTransactionIsolationLevel(): bool { | ||||
try { | try { | ||||
if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) { | |||||
if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) { | |||||
return true; | return true; | ||||
} | } | ||||
]; | ]; | ||||
$schema = new SchemaWrapper($this->db); | $schema = new SchemaWrapper($this->db); | ||||
$isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform; | |||||
$isSqlite = $this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE; | |||||
$pendingColumns = []; | $pendingColumns = []; | ||||
foreach ($tables as $tableName => $columns) { | foreach ($tables as $tableName => $columns) { |
use Doctrine\DBAL\Exception; | use Doctrine\DBAL\Exception; | ||||
use Doctrine\DBAL\Platforms\AbstractPlatform; | 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 Doctrine\DBAL\Schema\Schema; | ||||
use OC\DB\Exceptions\DbalException; | use OC\DB\Exceptions\DbalException; | ||||
use OCP\DB\IPreparedStatement; | use OCP\DB\IPreparedStatement; | ||||
public function getInner(): Connection { | public function getInner(): Connection { | ||||
return $this->inner; | return $this->inner; | ||||
} | } | ||||
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'); | |||||
} | |||||
} | |||||
} | } |
* @since 6.0.0 | * @since 6.0.0 | ||||
*/ | */ | ||||
interface IDBConnection { | interface IDBConnection { | ||||
/* @since 28.0.0 */ | |||||
public const PLATFORM_MYSQL = 'mysql'; | |||||
/* @since 28.0.0 */ | |||||
public const PLATFORM_ORACLE = 'oracle'; | |||||
/* @since 28.0.0 */ | |||||
public const PLATFORM_POSTGRES = 'postgres'; | |||||
/* @since 28.0.0 */ | |||||
public const PLATFORM_SQLITE = 'sqlite'; | |||||
/** | /** | ||||
* Gets the QueryBuilder for the connection. | * Gets the QueryBuilder for the connection. | ||||
* | * | ||||
* @since 13.0.0 | * @since 13.0.0 | ||||
*/ | */ | ||||
public function migrateToSchema(Schema $toSchema): void; | public function migrateToSchema(Schema $toSchema): void; | ||||
/** | |||||
* Returns the database provider name | |||||
* @link https://github.com/nextcloud/server/issues/30877 | |||||
* @since 28.0.0 | |||||
* @return IDBConnection::PLATFORM_* | |||||
*/ | |||||
public function getDatabaseProvider(): string; | |||||
} | } |