Skip to content

Commit

Permalink
Replace || by concat on postgreSQLPlatform doctrine/orm#3938
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Bettini committed Mar 4, 2020
1 parent 9e880d9 commit ed9b3d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ public function getLocateExpression($str, $substr, $startPos = false)
return 'POSITION(' . $substr . ' IN ' . $str . ')';
}

/**
* {@inheritDoc}
*/
public function getConcatExpression()
{
return sprintf('CONCAT(%s)', implode(', ', func_get_args()));
}

/**
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function testGeneratesSqlSnippets() : void
{
self::assertEquals('SIMILAR TO', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct');
self::assertEquals('"', $this->platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
self::assertEquals('column1 || column2 || column3', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
self::assertEquals('CONCAT(column1, column2, column3)', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
self::assertEquals('SUBSTRING(column FROM 5)', $this->platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
self::assertEquals('SUBSTRING(column FROM 1 FOR 5)', $this->platform->getSubstringExpression('column', 1, 5), 'Substring expression with length is not correct');
}
Expand Down

0 comments on commit ed9b3d2

Please sign in to comment.