diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 0baabe0da..2f5489778 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -2897,7 +2897,8 @@ class DboSource extends DataSource { $isKey = ( strpos($key, '(') !== false || strpos($key, ')') !== false || - strpos($key, '|') !== false + strpos($key, '|') !== false || + strpos($key, '->') !== false ); $key = $isKey ? $this->_quoteFields($key) : $this->name($key); } diff --git a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php index fa247d382..0ce8a937a 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php @@ -244,15 +244,16 @@ class DboSourceTest extends CakeTestCase { } /** - * test that PostgreSQL json operators can be used. + * test that SQL JSON operators can be used. * * @return void */ public function testColumnHyphenOperator() { $result = $this->testDb->conditions(array('Foo.bar->>\'fieldName\'' => 42)); - echo "Result is: "; - echo $result; - $this->assertEquals(' WHERE `Foo`.`bar`->>\'fieldName\' = 42', $result, 'pgsql json operator failed'); + $this->assertEquals(' WHERE `Foo`.`bar`->>\'fieldName\' = 42', $result, 'SQL JSON operator failed'); + + $result = $this->testDb->conditions(array('Foo.bar->\'fieldName\'' => 42)); + $this->assertEquals(' WHERE `Foo`.`bar`->\'fieldName\' = 42', $result, 'SQL JSON operator failed'); } /**