Commit 01445d99 authored by Stéphane Klein's avatar Stéphane Klein

Fixed generated sql for postgres substring function

parent 5dd0adfe
......@@ -57,10 +57,10 @@ class PostgreSqlPlatform extends AbstractPlatform
public function getSubstringExpression($value, $from, $length = null)
{
if ($length === null) {
return 'SUBSTR(' . $value . ', ' . $from . ')';
return 'SUBSTRING(' . $value . ' FROM ' . $from . ')';
}
return 'SUBSTR(' . $value . ', ' . $from . ', ' . $length . ')';
return 'SUBSTRING(' . $value . ' FROM ' . $from . ' FOR ' . $length . ')';
}
/**
......
......@@ -106,8 +106,8 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
$this->assertEquals('SIMILAR TO', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
$this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
$this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
$this->assertEquals('SUBSTR(column, 5)', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
$this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct');
$this->assertEquals('SUBSTRING(column FROM 5)', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
$this->assertEquals('SUBSTRING(column FROM 1 FOR 5)', $this->_platform->getSubstringExpression('column', 1, 5), 'Substring expression with length is not correct');
}
public function testGeneratesTransactionCommands()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment