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;
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();
+ }
}
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();
+ }
}
*/
namespace OC\DB\QueryBuilder\FunctionBuilder;
+use OC\DB\Connection;
use OC\DB\QueryBuilder\QueryFunction;
use OC\DB\QueryBuilder\QuoteHelper;
use OCP\DB\QueryBuilder\IFunctionBuilder;
use OCP\IDBConnection;
class FunctionBuilder implements IFunctionBuilder {
- /** @var IDBConnection */
+ /** @var IDBConnection|Connection */
protected $connection;
/** @var IQueryBuilder */
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) .')))');
}