Browse Source

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

tags/v28.0.0beta1
Anna 9 months ago
parent
commit
b6761fbc96
No account linked to committer's email address

+ 2
- 2
apps/settings/lib/Controller/CheckSetupController.php View File



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) {

+ 19
- 0
lib/private/DB/ConnectionAdapter.php View File



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');
}
}
} }

+ 20
- 0
lib/public/IDBConnection.php View File

* @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;
} }

Loading…
Cancel
Save