Skip to content
Permalink
Browse files

Fix incorrectly quoted fields when using the || operator.

Fixes #3404
  • Loading branch information...
markstory committed Dec 3, 2012
1 parent 0b508b8 commit 002700071d70c47b580f56e09e82dfeba512531f
@@ -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

This comment has been minimized.

@dereuromark

dereuromark Dec 3, 2012

Member

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

This comment has been minimized.

@markstory

markstory Dec 3, 2012

Author Member

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

);
$key = $isKey ? $this->_quoteFields($key) : $this->name($key);
}
@@ -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);

0 comments on commit 0027000

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.