Makes DboSource less string dependent.

This commit is contained in:
Frank de Graaf 2013-10-22 14:29:36 +02:00
parent dcffa923bc
commit ab89f6ec97
3 changed files with 6 additions and 6 deletions

View file

@ -1072,7 +1072,7 @@ class DboSource extends DataSource {
}
}
$query = trim($this->generateAssociationQuery($model, null, null, null, null, $queryData, false, $null));
$query = $this->generateAssociationQuery($model, null, null, null, null, $queryData, false, $null);
$resultSet = $this->fetchAll($query, $model->cacheQueries);
@ -1749,19 +1749,19 @@ class DboSource extends DataSource {
switch (strtolower($type)) {
case 'select':
return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}";
return trim("SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}");
case 'create':
return "INSERT INTO {$table} ({$fields}) VALUES ({$values})";
case 'update':
if (!empty($alias)) {
$aliases = "{$this->alias}{$alias} {$joins} ";
}
return "UPDATE {$table} {$aliases}SET {$fields} {$conditions}";
return trim("UPDATE {$table} {$aliases}SET {$fields} {$conditions}");
case 'delete':
if (!empty($alias)) {
$aliases = "{$this->alias}{$alias} {$joins} ";
}
return "DELETE {$alias} FROM {$table} {$aliases}{$conditions}";
return trim("DELETE {$alias} FROM {$table} {$aliases}{$conditions}");
case 'schema':
foreach (array('columns', 'indexes', 'tableParameters') as $var) {
if (is_array(${$var})) {

View file

@ -1198,7 +1198,7 @@ class MysqlTest extends CakeTestCase {
$this->assertRegExp('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel4Parent`\.`id`, `TestModel4Parent`\.`name`, `TestModel4Parent`\.`created`, `TestModel4Parent`\.`updated`\s+/', $result);
$this->assertRegExp('/FROM\s+\S+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+\S+`test_model4` AS `TestModel4Parent`/', $result);
$this->assertRegExp('/\s+ON\s+\(`TestModel4`.`parent_id` = `TestModel4Parent`.`id`\)\s+WHERE/', $result);
$this->assertRegExp('/\s+WHERE\s+1 = 1\s+$/', $result);
$this->assertRegExp('/\s+WHERE\s+1 = 1$/', $result);
$params['assocData']['type'] = 'INNER';
$this->Model->belongsTo['TestModel4Parent']['type'] = 'INNER';

View file

@ -1143,7 +1143,7 @@ class DboSourceTest extends CakeTestCase {
),
$this->Model
);
$expected = 'SELECT DISTINCT(AssetsTag.asset_id) FROM assets_tags AS AssetsTag WHERE Tag.name = foo bar GROUP BY AssetsTag.asset_id ';
$expected = 'SELECT DISTINCT(AssetsTag.asset_id) FROM assets_tags AS AssetsTag WHERE Tag.name = foo bar GROUP BY AssetsTag.asset_id';
$this->assertEquals($expected, $subQuery);
}