Navigation Menu

Skip to content

Commit

Permalink
Makes DboSource less string dependent.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phally committed Oct 22, 2013
1 parent dcffa92 commit ab89f6e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -1072,7 +1072,7 @@ public function read(Model $model, $queryData = array(), $recursive = null) {
}
}

$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);

Expand Down Expand Up @@ -1749,19 +1749,19 @@ public function renderStatement($type, $data) {

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})) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Expand Up @@ -1198,7 +1198,7 @@ public function testGenerateAssociationQuerySelfJoin() {
$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';
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
Expand Up @@ -1143,7 +1143,7 @@ public function testBuildStatementDefaults() {
),
$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);
}

Expand Down

0 comments on commit ab89f6e

Please sign in to comment.