Skip to content

Commit

Permalink
Merge pull request #5129 from morozov/get-expression-string
Browse files Browse the repository at this point in the history
Accept strings in AbstractPlatform::get*Expression() methods
  • Loading branch information
morozov authored Dec 19, 2021
2 parents decf34a + ee571fb commit 9a95d47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Platforms/PostgreSQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . ')';
Expand Down

0 comments on commit 9a95d47

Please sign in to comment.