Skip to content
Permalink
Browse files

Allow database JSON operations in conditions

  • Loading branch information...
coryjthompson committed Jan 24, 2017
1 parent 82a64a3 commit 990d0a962f3897f41ef3eae95be855b9ffbd66df
@@ -2897,7 +2897,8 @@ protected function _parseKey($key, $value, Model $Model = null) {
$isKey = (
strpos($key, '(') !== false ||
strpos($key, ')') !== false ||
strpos($key, '|') !== false
strpos($key, '|') !== false ||
strpos($key, '->') !== false
);
$key = $isKey ? $this->_quoteFields($key) : $this->name($key);
}
@@ -244,15 +244,16 @@ public function testBooleanEmptyConditionsParsing() {
}
/**
* 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');
}
/**

0 comments on commit 990d0a9

Please sign in to comment.
You can’t perform that action at this time.