Merge pull request #40423 from nextcloud/enh/proved-db-as-string

pull/40504/head
Anna 9 months ago committed by GitHub
commit b6761fbc96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -641,7 +641,7 @@ Raw output
protected function hasValidTransactionIsolationLevel(): bool {
try {
if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) {
return true;
}
@ -839,7 +839,7 @@ Raw output
];
$schema = new SchemaWrapper($this->db);
$isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
$isSqlite = $this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE;
$pendingColumns = [];
foreach ($tables as $tableName => $columns) {

@ -27,6 +27,10 @@ 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;
@ -242,4 +246,19 @@ class ConnectionAdapter implements IDBConnection {
public function getInner(): Connection {
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');
}
}
}

@ -45,6 +45,18 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
* @since 6.0.0
*/
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.
*
@ -339,4 +351,12 @@ interface IDBConnection {
* @since 13.0.0
*/
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;
}

Loading…
Cancel
Save