mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Allow database JSON operations in conditions
This commit is contained in:
parent
82a64a3729
commit
990d0a962f
2 changed files with 7 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue