fix(db): Fix md5 for oracle >= 20

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/46605/head
Joas Schilling 4 months ago
parent 817ca0045a
commit b656edc47c
No known key found for this signature in database
GPG Key ID: 74434EFE0D2E2205
  1. 10
      lib/private/DB/Connection.php
  2. 8
      lib/private/DB/ConnectionAdapter.php
  3. 3
      lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
  4. 3
      lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php

@ -13,6 +13,7 @@ use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\ConnectionLost;
use Doctrine\DBAL\Platforms\MySQLPlatform;
@ -749,4 +750,13 @@ class Connection extends PrimaryReadReplicaConnection {
throw new \Exception('Database ' . $platform::class . ' not supported');
}
}
/**
* @internal Should only be used inside the QueryBuilder, ExpressionBuilder and FunctionBuilder
* All apps and API code should not need this and instead use provided functionality from the above.
*/
public function getServerVersion(): string {
/** @var ServerInfoAwareConnection $this->_conn */
return $this->_conn->getServerVersion();
}
}

@ -232,4 +232,12 @@ class ConnectionAdapter implements IDBConnection {
public function getDatabaseProvider(): string {
return $this->inner->getDatabaseProvider();
}
/**
* @internal Should only be used inside the QueryBuilder, ExpressionBuilder and FunctionBuilder
* All apps and API code should not need this and instead use provided functionality from the above.
*/
public function getServerVersion(): string {
return $this->inner->getServerVersion();
}
}

@ -5,6 +5,7 @@
*/
namespace OC\DB\QueryBuilder\FunctionBuilder;
use OC\DB\Connection;
use OC\DB\QueryBuilder\QueryFunction;
use OC\DB\QueryBuilder\QuoteHelper;
use OCP\DB\QueryBuilder\IFunctionBuilder;
@ -13,7 +14,7 @@ use OCP\DB\QueryBuilder\IQueryFunction;
use OCP\IDBConnection;
class FunctionBuilder implements IFunctionBuilder {
/** @var IDBConnection */
/** @var IDBConnection|Connection */
protected $connection;
/** @var IQueryBuilder */

@ -12,6 +12,9 @@ use OCP\DB\QueryBuilder\IQueryFunction;
class OCIFunctionBuilder extends FunctionBuilder {
public function md5($input): IQueryFunction {
if (version_compare($this->connection->getServerVersion(), '20', '>=')) {
return new QueryFunction('LOWER(STANDARD_HASH(' . $this->helper->quoteColumnName($input) . ", 'MD5'))");
}
return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))');
}

Loading…
Cancel
Save