0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-03-14 16:33:21 +00:00
nextcloud_server/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2016-02-05 14:32:34 +00:00
<?php
2016-02-05 14:32:34 +00:00
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
2016-02-05 14:32:34 +00:00
*/
namespace OC\DB\QueryBuilder\ExpressionBuilder;
use OC\DB\QueryBuilder\QueryFunction;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\QueryBuilder\IQueryFunction;
2016-02-05 14:32:34 +00:00
class PgSqlExpressionBuilder extends ExpressionBuilder {
/**
* Returns a IQueryFunction that casts the column to the given type
*
* @param string|IQueryFunction $column
2016-02-05 14:32:34 +00:00
* @param mixed $type One of IQueryBuilder::PARAM_*
* @psalm-param IQueryBuilder::PARAM_* $type
* @return IQueryFunction
2016-02-05 14:32:34 +00:00
*/
public function castColumn($column, $type): IQueryFunction {
switch ($type) {
case IQueryBuilder::PARAM_INT:
return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS BIGINT)');
case IQueryBuilder::PARAM_STR:
return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS TEXT)');
default:
return parent::castColumn($column, $type);
2016-02-05 14:32:34 +00:00
}
}
2016-02-22 18:46:37 +00:00
/**
* @inheritdoc
*/
public function iLike($x, $y, $type = null): string {
2016-02-22 18:46:37 +00:00
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->comparison($x, 'ILIKE', $y);
2016-02-22 18:46:37 +00:00
}
2016-02-05 14:32:34 +00:00
}