Commit 168eac3a authored by Steve Müller's avatar Steve Müller

fix LOCATE expression on SQL Anywhere

parent 7c68e80f
...@@ -971,10 +971,10 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -971,10 +971,10 @@ class SQLAnywherePlatform extends AbstractPlatform
public function getLocateExpression($str, $substr, $startPos = false) public function getLocateExpression($str, $substr, $startPos = false)
{ {
if ($startPos == false) { if ($startPos == false) {
return 'CHARINDEX(' . $substr . ', ' . $str . ')'; return 'LOCATE(' . $str . ', ' . $substr . ')';
} }
return 'CHARINDEX(' . $substr . ', SUBSTR(' . $str . ', ' . ($startPos + 1) . '))'; return 'LOCATE(' . $str . ', ' . $substr . ', ' . $startPos . ')';
} }
/** /**
......
...@@ -544,9 +544,8 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase ...@@ -544,9 +544,8 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
$this->assertEquals("H:i:s.u", $this->_platform->getTimeFormatString()); $this->assertEquals("H:i:s.u", $this->_platform->getTimeFormatString());
$this->assertEquals('FOR UPDATE BY LOCK', $this->_platform->getForUpdateSQL()); $this->assertEquals('FOR UPDATE BY LOCK', $this->_platform->getForUpdateSQL());
$this->assertEquals('NEWID()', $this->_platform->getGuidExpression()); $this->assertEquals('NEWID()', $this->_platform->getGuidExpression());
$this->assertEquals('CHARINDEX(substring_column, string_column)', $this->_platform->getLocateExpression('string_column', 'substring_column')); $this->assertEquals('LOCATE(string_column, substring_column)', $this->_platform->getLocateExpression('string_column', 'substring_column'));
$this->assertEquals('CHARINDEX(substring_column, string_column)', $this->_platform->getLocateExpression('string_column', 'substring_column')); $this->assertEquals('LOCATE(string_column, substring_column, 1)', $this->_platform->getLocateExpression('string_column', 'substring_column', 1));
$this->assertEquals('CHARINDEX(substring_column, SUBSTR(string_column, 2))', $this->_platform->getLocateExpression('string_column', 'substring_column', 1));
$this->assertEquals("HASH(column, 'MD5')", $this->_platform->getMd5Expression('column')); $this->assertEquals("HASH(column, 'MD5')", $this->_platform->getMd5Expression('column'));
$this->assertEquals('SUBSTRING(column, 5)', $this->_platform->getSubstringExpression('column', 5)); $this->assertEquals('SUBSTRING(column, 5)', $this->_platform->getSubstringExpression('column', 5));
$this->assertEquals('SUBSTRING(column, 5, 2)', $this->_platform->getSubstringExpression('column', 5, 2)); $this->assertEquals('SUBSTRING(column, 5, 2)', $this->_platform->getSubstringExpression('column', 5, 2));
......
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