Fixing test for DboSource::expression(), moving $startQuote and $endQuote from DboSource to DataSource.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7859 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-11-10 18:57:50 +00:00
parent dde4906195
commit 1a6a0d1788
3 changed files with 34 additions and 24 deletions

View file

@ -75,6 +75,18 @@ class DataSource extends Object {
* @access public
*/
var $took = null;
/**
* The starting character that this DataSource uses for quoted identifiers.
*
* @var string
*/
var $startQuote = null;
/**
* The ending character that this DataSource uses for quoted identifiers.
*
* @var string
*/
var $endQuote = null;
/**
* Enter description here...
*

View file

@ -48,21 +48,9 @@ class DboSource extends DataSource {
*/
var $index = array('PRI' => 'primary', 'MUL' => 'index', 'UNI' => 'unique');
/**
* Enter description here...
* Database keyword used to assign aliases to identifiers.
*
* @var unknown_type
*/
var $startQuote = null;
/**
* Enter description here...
*
* @var unknown_type
*/
var $endQuote = null;
/**
* Enter description here...
*
* @var unknown_type
* @var string
*/
var $alias = 'AS ';
/**
@ -72,9 +60,9 @@ class DboSource extends DataSource {
*/
var $fieldCache = array();
/**
* Enter description here...
* Bypass automatic adding of joined fields/associations.
*
* @var unknown_type
* @var boolean
*/
var $__bypass = false;
/**
@ -1824,8 +1812,12 @@ class DboSource extends DataSource {
if ($value->type == 'identifier') {
$data .= $this->name($key) . ' = ' . $this->name($value->value);
} elseif ($value->type == 'expression') {
if (is_numeric($key)) {
$data .= $value->value;
} else {
$data .= $this->name($key) . ' = ' . $value->value;
}
}
} elseif (is_array($value) && !empty($value) && !$valueInsert) {
$keys = array_keys($value);
if (array_keys($value) === array_values(array_keys($value))) {

View file

@ -1659,7 +1659,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
/**
* test find('count'') method
* test find('count') method
*
* @access public
* @return void
@ -1684,12 +1684,6 @@ class ModelTest extends CakeTestCase {
$this->db->_queriesLog = array();
$this->db->fullDebug = $fullDebug;
$db = ConnectionManager::getDataSource('test_suite');
$result = $TestModel->find('count', array('conditions' => array(
$db->expression('Project.name = \'Project 3\'')
)));
$this->assertEqual($result, 1);
$TestModel =& new Project();
$TestModel->create(array('name' => 'project')) && $TestModel->save();
$TestModel->create(array('name' => 'project')) && $TestModel->save();
@ -1697,6 +1691,18 @@ class ModelTest extends CakeTestCase {
$result = $TestModel->find('count', array('fields' => 'DISTINCT Project.name'));
$this->assertEqual($result, 4);
$db = ConnectionManager::getDataSource('test_suite');
$result = $TestModel->find('count', array('conditions' => array(
$db->expression('Project.name = \'Project 3\'')
)));
$this->assertEqual($result, 1);
$result = $TestModel->find('count', array('conditions' => array(
'Project.name' => $db->expression('\'Project 3\'')
)));
$this->assertEqual($result, 1);
}
/**
* testFindMagic method