Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix incorrectly quoted fields when using the || operator.

Fixes #3404
  • Loading branch information...
commit 002700071d70c47b580f56e09e82dfeba512531f 1 parent 0b508b8
@markstory markstory authored
View
6 lib/Cake/Model/Datasource/DboSource.php
@@ -2574,7 +2574,11 @@ protected function _parseKey($model, $key, $value) {
$value = $this->value($value, $type);
if (!$virtual && $key !== '?') {
- $isKey = (strpos($key, '(') !== false || strpos($key, ')') !== false);
+ $isKey = (
+ strpos($key, '(') !== false ||
+ strpos($key, ')') !== false ||
+ strpos($key, '|') !== false
@dereuromark Collaborator

wouldn't other operators like && etc still fail? or are they not supposed to used in this context?

@markstory Owner

|| is the concat operator in Postgres and SQLite. From what I remember && doesn't do anything special.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ );
$key = $isKey ? $this->_quoteFields($key) : $this->name($key);
}
View
6 lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
@@ -2207,6 +2207,12 @@ public function testArrayConditionsParsing() {
$expected = " WHERE `HardCandy`.`name` LIKE 'to be or%' AND `Candy`.`name` LIKE '%not to be%'";
$this->assertEquals($expected, $result);
+ $result = $this->Dbo->conditions(array(
+ "Person.name || ' ' || Person.surname ILIKE" => '%mark%'
+ ));
+ $expected = " WHERE `Person`.`name` || ' ' || `Person`.`surname` ILIKE '%mark%'";
+ $this->assertEquals($expected, $result);
+
$result = $this->Dbo->conditions(array('score BETWEEN ? AND ?' => array(90.1, 95.7)));
$expected = " WHERE `score` BETWEEN 90.1 AND 95.7";
$this->assertEquals($expected, $result);
Please sign in to comment.
Something went wrong with that request. Please try again.