Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/private/DB/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\ConnectionLost;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
Expand Down Expand Up @@ -915,11 +916,13 @@ private function getConnectionName(): string {
}

/**
* @return IDBConnection::PLATFORM_MYSQL|IDBConnection::PLATFORM_ORACLE|IDBConnection::PLATFORM_POSTGRES|IDBConnection::PLATFORM_SQLITE
* @return IDBConnection::PLATFORM_MYSQL|IDBConnection::PLATFORM_ORACLE|IDBConnection::PLATFORM_POSTGRES|IDBConnection::PLATFORM_SQLITE|IDBConnection::PLATFORM_MARIADB
*/
public function getDatabaseProvider(): string {
public function getDatabaseProvider(bool $strict = false): string {
$platform = $this->getDatabasePlatform();
if ($platform instanceof MySQLPlatform) {
if ($strict && $platform instanceof MariaDBPlatform) {
return IDBConnection::PLATFORM_MARIADB;
} elseif ($platform instanceof MySQLPlatform) {
return IDBConnection::PLATFORM_MYSQL;
} elseif ($platform instanceof OraclePlatform) {
return IDBConnection::PLATFORM_ORACLE;
Expand Down
6 changes: 3 additions & 3 deletions lib/private/DB/ConnectionAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ public function getInner(): Connection {
}

/**
* @return self::PLATFORM_MYSQL|self::PLATFORM_ORACLE|self::PLATFORM_POSTGRES|self::PLATFORM_SQLITE
* @return self::PLATFORM_MYSQL|self::PLATFORM_ORACLE|self::PLATFORM_POSTGRES|self::PLATFORM_SQLITE|self::PLATFORM_MARIADB
*/
public function getDatabaseProvider(): string {
return $this->inner->getDatabaseProvider();
public function getDatabaseProvider(bool $strict = false): string {
return $this->inner->getDatabaseProvider($strict);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/private/DB/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function expr() {
return match($this->connection->getDatabaseProvider()) {
IDBConnection::PLATFORM_ORACLE => new OCIExpressionBuilder($this->connection, $this, $this->logger),
IDBConnection::PLATFORM_POSTGRES => new PgSqlExpressionBuilder($this->connection, $this, $this->logger),
IDBConnection::PLATFORM_MARIADB,
IDBConnection::PLATFORM_MYSQL => new MySqlExpressionBuilder($this->connection, $this, $this->logger),
IDBConnection::PLATFORM_SQLITE => new SqliteExpressionBuilder($this->connection, $this, $this->logger),
};
Expand All @@ -121,6 +122,7 @@ public function func() {
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_MARIADB,
IDBConnection::PLATFORM_MYSQL => new FunctionBuilder($this->connection, $this, $this->helper),
IDBConnection::PLATFORM_SQLITE => new SqliteFunctionBuilder($this->connection, $this, $this->helper),
};
Expand Down
13 changes: 11 additions & 2 deletions lib/public/IDBConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ interface IDBConnection {
*/
public const PLATFORM_SQLITE = 'sqlite';

/**
* @since 32.0.0
*/
public const PLATFORM_MARIADB = 'mariadb';

/**
* Gets the QueryBuilder for the connection.
*
Expand Down Expand Up @@ -357,11 +362,15 @@ public function migrateToSchema(Schema $toSchema): void;

/**
* Returns the database provider name
*
* @link https://github.com/nextcloud/server/issues/30877
*
* @param bool $strict differentiate between database flavors, e.g. MySQL vs MariaDB
* @return self::PLATFORM_MYSQL|self::PLATFORM_ORACLE|self::PLATFORM_POSTGRES|self::PLATFORM_SQLITE|self::PLATFORM_MARIADB
* @since 32.0.0 Optional parameter $strict was added
* @since 28.0.0
* @return self::PLATFORM_MYSQL|self::PLATFORM_ORACLE|self::PLATFORM_POSTGRES|self::PLATFORM_SQLITE
*/
public function getDatabaseProvider(): string;
public function getDatabaseProvider(bool $strict = false): string;

/**
* Get the shard definition by name, if configured
Expand Down
Loading