Permalink
Browse files

Makes DboSource less string dependent.

  • Loading branch information...
1 parent dcffa92 commit ab89f6ec97e0574995a344fcf900efdf4c9550fe @Phally Phally committed Oct 22, 2013
@@ -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);
@@ -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})) {
@@ -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';
@@ -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);
}

0 comments on commit ab89f6e

Please sign in to comment.