Skip to content

Commit

Permalink
Finished removal of top level keys for in results
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 19, 2013
1 parent a62c6ca commit dbcb723
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
8 changes: 5 additions & 3 deletions lib/Cake/ORM/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ protected function _groupResult() {
}
}

$parts = $this->_map[$key];
list($table, $field) = $parts;
$value = $this->_castValue($table, $field, $value);
if (!empty($this->_map[$key])) {
$parts = $this->_map[$key];
list($table, $field) = $parts;
$value = $this->_castValue($table, $field, $value);
}

if (!empty($parts[2])) {
$results[$parts[2]][$field] = $value;
Expand Down
18 changes: 9 additions & 9 deletions lib/Cake/Test/TestCase/ORM/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public function testFindAllNoFields() {
$table = new Table(['table' => 'things', 'connection' => $this->connection]);
$results = $table->find('all')->toArray();
$expected = [
['things' => ['id' => 1, 'title' => 'a title', 'body' => 'a body']],
['things' => ['id' => 2, 'title' => 'another title', 'body' => 'another body']]
['id' => 1, 'title' => 'a title', 'body' => 'a body'],
['id' => 2, 'title' => 'another title', 'body' => 'another body']
];
$this->assertSame($expected, $results);
}
Expand All @@ -162,15 +162,15 @@ public function testFindAllSomeFields() {
$table = new Table(['table' => 'things', 'connection' => $this->connection]);
$results = $table->find('all')->select(['id', 'title'])->toArray();
$expected = [
['things' => ['id' => 1, 'title' => 'a title']],
['things' => ['id' => 2, 'title' => 'another title']]
['id' => 1, 'title' => 'a title'],
['id' => 2, 'title' => 'another title']
];
$this->assertSame($expected, $results);

$results = $table->find('all')->select(['id', 'foo' => 'title'])->toArray();
$expected = [
['things' => ['id' => 1, 'foo' => 'a title']],
['things' => ['id' => 2, 'foo' => 'another title']]
['id' => 1, 'foo' => 'a title'],
['id' => 2, 'foo' => 'another title']
];
$this->assertSame($expected, $results);
}
Expand All @@ -182,14 +182,14 @@ public function testFindAllConditionAutoTypes() {
->select(['id', 'name'])
->where(['posted >=' => new \DateTime('2012-12-22 12:01')]);
$expected = [
['dates' => ['id' => 3, 'name' => 'Jet Li']]
['id' => 3, 'name' => 'Jet Li']
];
$this->assertSame($expected, $query->toArray());

$query->orWhere(['dates.posted' => new \DateTime('2012-12-22 12:00')]);
$expected = [
['dates' => ['id' => 2, 'name' => 'Bruce Lee']],
['dates' => ['id' => 3, 'name' => 'Jet Li']]
['id' => 2, 'name' => 'Bruce Lee'],
['id' => 3, 'name' => 'Jet Li']
];
$this->assertSame($expected, $query->toArray());
}
Expand Down

0 comments on commit dbcb723

Please sign in to comment.