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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OC\DB\QueryBuilder\Literal;
use OC\DB\QueryBuilder\QueryFunction;
use OC\DB\QueryBuilder\QuoteHelper;
use OCP\DB\QueryBuilder\ICompositeExpression;
use OCP\DB\QueryBuilder\IExpressionBuilder;
use OCP\DB\QueryBuilder\ILiteral;
use OCP\DB\QueryBuilder\IParameter;
Expand Down Expand Up @@ -80,7 +81,7 @@ public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryB
*
* @return \OCP\DB\QueryBuilder\ICompositeExpression
*/
public function andX(...$x) {
public function andX(...$x): ICompositeExpression {
$compositeExpression = call_user_func_array([$this->expressionBuilder, 'andX'], $x);
return new CompositeExpression($compositeExpression);
}
Expand All @@ -99,7 +100,7 @@ public function andX(...$x) {
*
* @return \OCP\DB\QueryBuilder\ICompositeExpression
*/
public function orX(...$x) {
public function orX(...$x): ICompositeExpression {
$compositeExpression = call_user_func_array([$this->expressionBuilder, 'orX'], $x);
return new CompositeExpression($compositeExpression);
}
Expand All @@ -115,7 +116,7 @@ public function orX(...$x) {
*
* @return string
*/
public function comparison($x, $operator, $y, $type = null) {
public function comparison($x, string $operator, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->comparison($x, $operator, $y);
Expand All @@ -138,7 +139,7 @@ public function comparison($x, $operator, $y, $type = null) {
*
* @return string
*/
public function eq($x, $y, $type = null) {
public function eq($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->eq($x, $y);
Expand All @@ -160,7 +161,7 @@ public function eq($x, $y, $type = null) {
*
* @return string
*/
public function neq($x, $y, $type = null) {
public function neq($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->neq($x, $y);
Expand All @@ -182,7 +183,7 @@ public function neq($x, $y, $type = null) {
*
* @return string
*/
public function lt($x, $y, $type = null) {
public function lt($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->lt($x, $y);
Expand All @@ -204,7 +205,7 @@ public function lt($x, $y, $type = null) {
*
* @return string
*/
public function lte($x, $y, $type = null) {
public function lte($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->lte($x, $y);
Expand All @@ -226,7 +227,7 @@ public function lte($x, $y, $type = null) {
*
* @return string
*/
public function gt($x, $y, $type = null) {
public function gt($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->gt($x, $y);
Expand All @@ -248,7 +249,7 @@ public function gt($x, $y, $type = null) {
*
* @return string
*/
public function gte($x, $y, $type = null) {
public function gte($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->gte($x, $y);
Expand All @@ -257,23 +258,23 @@ public function gte($x, $y, $type = null) {
/**
* Creates an IS NULL expression with the given arguments.
*
* @param string $x The field in string format to be restricted by IS NULL.
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL.
*
* @return string
*/
public function isNull($x) {
public function isNull($x): string {
$x = $this->helper->quoteColumnName($x);
return $this->expressionBuilder->isNull($x);
}

/**
* Creates an IS NOT NULL expression with the given arguments.
*
* @param string $x The field in string format to be restricted by IS NOT NULL.
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL.
*
* @return string
*/
public function isNotNull($x) {
public function isNotNull($x): string {
$x = $this->helper->quoteColumnName($x);
return $this->expressionBuilder->isNotNull($x);
}
Expand All @@ -288,7 +289,7 @@ public function isNotNull($x) {
*
* @return string
*/
public function like($x, $y, $type = null) {
public function like($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->like($x, $y);
Expand All @@ -305,7 +306,7 @@ public function like($x, $y, $type = null) {
* @return string
* @since 9.0.0
*/
public function iLike($x, $y, $type = null) {
public function iLike($x, $y, $type = null): string {
return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y));
}

Expand All @@ -319,7 +320,7 @@ public function iLike($x, $y, $type = null) {
*
* @return string
*/
public function notLike($x, $y, $type = null) {
public function notLike($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->notLike($x, $y);
Expand All @@ -335,7 +336,7 @@ public function notLike($x, $y, $type = null) {
*
* @return string
*/
public function in($x, $y, $type = null) {
public function in($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnNames($y);
return $this->expressionBuilder->in($x, $y);
Expand All @@ -351,7 +352,7 @@ public function in($x, $y, $type = null) {
*
* @return string
*/
public function notIn($x, $y, $type = null) {
public function notIn($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnNames($y);
return $this->expressionBuilder->notIn($x, $y);
Expand All @@ -360,22 +361,22 @@ public function notIn($x, $y, $type = null) {
/**
* Creates a $x = '' statement, because Oracle needs a different check
*
* @param string $x The field in string format to be inspected by the comparison.
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
* @return string
* @since 13.0.0
*/
public function emptyString($x) {
public function emptyString($x): string {
return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR));
}

/**
* Creates a `$x <> ''` statement, because Oracle needs a different check
*
* @param string $x The field in string format to be inspected by the comparison.
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
* @return string
* @since 13.0.0
*/
public function nonEmptyString($x) {
public function nonEmptyString($x): string {
return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR));
}

Expand All @@ -387,7 +388,7 @@ public function nonEmptyString($x) {
* @return IQueryFunction
* @since 12.0.0
*/
public function bitwiseAnd($x, $y) {
public function bitwiseAnd($x, int $y): IQueryFunction {
return new QueryFunction($this->connection->getDatabasePlatform()->getBitAndComparisonExpression(
$this->helper->quoteColumnName($x),
$y
Expand All @@ -402,7 +403,7 @@ public function bitwiseAnd($x, $y) {
* @return IQueryFunction
* @since 12.0.0
*/
public function bitwiseOr($x, $y) {
public function bitwiseOr($x, int $y): IQueryFunction {
return new QueryFunction($this->connection->getDatabasePlatform()->getBitOrComparisonExpression(
$this->helper->quoteColumnName($x),
$y
Expand All @@ -417,7 +418,7 @@ public function bitwiseOr($x, $y) {
*
* @return ILiteral
*/
public function literal($input, $type = null) {
public function literal($input, $type = null): ILiteral {
return new Literal($this->expressionBuilder->literal($input, $type));
}

Expand All @@ -426,9 +427,9 @@ public function literal($input, $type = null) {
*
* @param string $column
* @param mixed $type One of IQueryBuilder::PARAM_*
* @return string
* @return IQueryFunction
*/
public function castColumn($column, $type) {
public function castColumn(string $column, $type): IQueryFunction {
return new QueryFunction(
$this->helper->quoteColumnName($column)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryB
/**
* @inheritdoc
*/
public function iLike($x, $y, $type = null) {
public function iLike($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->charset . '_general_ci LIKE', $y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function prepareColumn($column, $type) {
/**
* @inheritdoc
*/
public function comparison($x, $operator, $y, $type = null) {
public function comparison($x, string $operator, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);

Expand All @@ -59,7 +59,7 @@ public function comparison($x, $operator, $y, $type = null) {
/**
* @inheritdoc
*/
public function eq($x, $y, $type = null) {
public function eq($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);

Expand All @@ -69,7 +69,7 @@ public function eq($x, $y, $type = null) {
/**
* @inheritdoc
*/
public function neq($x, $y, $type = null) {
public function neq($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);

Expand All @@ -79,7 +79,7 @@ public function neq($x, $y, $type = null) {
/**
* @inheritdoc
*/
public function lt($x, $y, $type = null) {
public function lt($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);

Expand All @@ -89,7 +89,7 @@ public function lt($x, $y, $type = null) {
/**
* @inheritdoc
*/
public function lte($x, $y, $type = null) {
public function lte($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);

Expand All @@ -99,7 +99,7 @@ public function lte($x, $y, $type = null) {
/**
* @inheritdoc
*/
public function gt($x, $y, $type = null) {
public function gt($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);

Expand All @@ -109,7 +109,7 @@ public function gt($x, $y, $type = null) {
/**
* @inheritdoc
*/
public function gte($x, $y, $type = null) {
public function gte($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);

Expand All @@ -119,7 +119,7 @@ public function gte($x, $y, $type = null) {
/**
* @inheritdoc
*/
public function in($x, $y, $type = null) {
public function in($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);

Expand All @@ -129,7 +129,7 @@ public function in($x, $y, $type = null) {
/**
* @inheritdoc
*/
public function notIn($x, $y, $type = null) {
public function notIn($x, $y, $type = null): string {
$x = $this->prepareColumn($x, $type);
$y = $this->prepareColumn($y, $type);

Expand All @@ -139,22 +139,22 @@ public function notIn($x, $y, $type = null) {
/**
* Creates a $x = '' statement, because Oracle needs a different check
*
* @param string $x The field in string format to be inspected by the comparison.
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
* @return string
* @since 13.0.0
*/
public function emptyString($x) {
public function emptyString($x): string {
return $this->isNull($x);
}

/**
* Creates a `$x <> ''` statement, because Oracle needs a different check
*
* @param string $x The field in string format to be inspected by the comparison.
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
* @return string
* @since 13.0.0
*/
public function nonEmptyString($x) {
public function nonEmptyString($x): string {
return $this->isNotNull($x);
}

Expand All @@ -165,7 +165,7 @@ public function nonEmptyString($x) {
* @param mixed $type One of IQueryBuilder::PARAM_*
* @return IQueryFunction
*/
public function castColumn($column, $type) {
public function castColumn(string $column, $type): IQueryFunction {
if ($type === IQueryBuilder::PARAM_STR) {
$column = $this->helper->quoteColumnName($column);
return new QueryFunction('to_char(' . $column . ')');
Expand All @@ -181,14 +181,14 @@ public function castColumn($column, $type) {
/**
* @inheritdoc
*/
public function like($x, $y, $type = null) {
public function like($x, $y, $type = null): string {
return parent::like($x, $y, $type) . " ESCAPE '\\'";
}

/**
* @inheritdoc
*/
public function iLike($x, $y, $type = null) {
public function iLike($x, $y, $type = null): string {
return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use OC\DB\QueryBuilder\QueryFunction;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\QueryBuilder\IQueryFunction;

class PgSqlExpressionBuilder extends ExpressionBuilder {

Expand All @@ -34,9 +35,9 @@ class PgSqlExpressionBuilder extends ExpressionBuilder {
*
* @param string $column
* @param mixed $type One of IQueryBuilder::PARAM_*
* @return string
* @return IQueryFunction
*/
public function castColumn($column, $type) {
public function castColumn($column, $type): IQueryFunction {
switch ($type) {
case IQueryBuilder::PARAM_INT:
return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS INT)');
Expand All @@ -50,7 +51,7 @@ public function castColumn($column, $type) {
/**
* @inheritdoc
*/
public function iLike($x, $y, $type = null) {
public function iLike($x, $y, $type = null): string {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->comparison($x, 'ILIKE', $y);
Expand Down
Loading