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:
phpnut 2007-05-14 01:52:59 +00:00
parent 586fbc9dea
commit 9d02c911a6
2 changed files with 9 additions and 2 deletions

View file

@ -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) {

View file

@ -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`');