mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding tests and fixes for #2570, this corrects DboSource::conditions fails to quote mixed array/string conditions
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5087 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
586fbc9dea
commit
9d02c911a6
2 changed files with 9 additions and 2 deletions
|
@ -1545,8 +1545,8 @@ class DboSource extends DataSource {
|
|||
$out[] = $ret[0];
|
||||
}
|
||||
}
|
||||
} elseif (is_numeric($key)) {
|
||||
$data = ' ' . $value;
|
||||
} elseif (is_numeric($key) && !empty($value)) {
|
||||
$data = $this->__quoteFields($value);
|
||||
} elseif ($value === null || (is_array($value) && empty($value))) {
|
||||
$data = $this->name($key) . ' IS NULL';
|
||||
} elseif ($value === false || $value === true) {
|
||||
|
|
|
@ -1474,6 +1474,13 @@ class DboSourceTest extends UnitTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testMixedConditionsParsing(){
|
||||
$conditions[] = 'User.first_name = \'Firstname\'';
|
||||
$conditions[] = array('User.last_name' => 'Lastname');
|
||||
$result = $this->db->conditions($conditions);
|
||||
$expected = " WHERE `User`.`first_name` = 'Firstname' AND `User`.`last_name` = 'Lastname'";
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
function testFieldParsing() {
|
||||
$result = $this->db->fields($this->model, 'Vendor', "Vendor.id, COUNT(Model.vendor_id) AS `Vendor`.`count`");
|
||||
$expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`');
|
||||
|
|
Loading…
Reference in a new issue