From ee571fb0b73bf30f5fde39832596be6c9995cb4f Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 18 Dec 2021 20:35:23 -0800 Subject: [PATCH] Accept strings in AbstractPlatform::get*Expression() methods --- src/Platforms/AbstractPlatform.php | 16 ++++++++-------- src/Platforms/PostgreSQLPlatform.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Platforms/AbstractPlatform.php b/src/Platforms/AbstractPlatform.php index d8ee4ab358c..1f70fc32d7c 100644 --- a/src/Platforms/AbstractPlatform.php +++ b/src/Platforms/AbstractPlatform.php @@ -823,8 +823,8 @@ public function getSqrtExpression($column) * * @deprecated Use ROUND() in SQL instead. * - * @param string $column - * @param int $decimals + * @param string $column + * @param string|int $decimals * * @return string */ @@ -975,9 +975,9 @@ public function getLowerExpression($str) /** * Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str. * - * @param string $str Literal string. - * @param string $substr Literal string to find. - * @param int|false $startPos Position to start at, beginning of string by default. + * @param string $str Literal string. + * @param string $substr Literal string to find. + * @param string|int|false $startPos Position to start at, beginning of string by default. * * @return string * @@ -1013,9 +1013,9 @@ public function getNowExpression() * * SQLite only supports the 2 parameter variant of this function. * - * @param string $string An sql string literal or column name/alias. - * @param int $start Where to start the substring portion. - * @param int|null $length The substring portion length. + * @param string $string An sql string literal or column name/alias. + * @param string|int $start Where to start the substring portion. + * @param string|int|null $length The substring portion length. * * @return string */ diff --git a/src/Platforms/PostgreSQLPlatform.php b/src/Platforms/PostgreSQLPlatform.php index 98a2bb36fac..945cc7afa84 100644 --- a/src/Platforms/PostgreSQLPlatform.php +++ b/src/Platforms/PostgreSQLPlatform.php @@ -122,7 +122,7 @@ public function getLocateExpression($str, $substr, $startPos = false) $str = $this->getSubstringExpression($str, $startPos); return 'CASE WHEN (POSITION(' . $substr . ' IN ' . $str . ') = 0) THEN 0' - . ' ELSE (POSITION(' . $substr . ' IN ' . $str . ') + ' . ($startPos - 1) . ') END'; + . ' ELSE (POSITION(' . $substr . ' IN ' . $str . ') + ' . $startPos . ' - 1) END'; } return 'POSITION(' . $substr . ' IN ' . $str . ')';