Skip to content

Commit dbcb723

Browse files
committed
Finished removal of top level keys for in results
1 parent a62c6ca commit dbcb723

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

lib/Cake/ORM/ResultSet.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ protected function _groupResult() {
9494
}
9595
}
9696

97-
$parts = $this->_map[$key];
98-
list($table, $field) = $parts;
99-
$value = $this->_castValue($table, $field, $value);
97+
if (!empty($this->_map[$key])) {
98+
$parts = $this->_map[$key];
99+
list($table, $field) = $parts;
100+
$value = $this->_castValue($table, $field, $value);
101+
}
100102

101103
if (!empty($parts[2])) {
102104
$results[$parts[2]][$field] = $value;

lib/Cake/Test/TestCase/ORM/TableTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ public function testFindAllNoFields() {
151151
$table = new Table(['table' => 'things', 'connection' => $this->connection]);
152152
$results = $table->find('all')->toArray();
153153
$expected = [
154-
['things' => ['id' => 1, 'title' => 'a title', 'body' => 'a body']],
155-
['things' => ['id' => 2, 'title' => 'another title', 'body' => 'another body']]
154+
['id' => 1, 'title' => 'a title', 'body' => 'a body'],
155+
['id' => 2, 'title' => 'another title', 'body' => 'another body']
156156
];
157157
$this->assertSame($expected, $results);
158158
}
@@ -162,15 +162,15 @@ public function testFindAllSomeFields() {
162162
$table = new Table(['table' => 'things', 'connection' => $this->connection]);
163163
$results = $table->find('all')->select(['id', 'title'])->toArray();
164164
$expected = [
165-
['things' => ['id' => 1, 'title' => 'a title']],
166-
['things' => ['id' => 2, 'title' => 'another title']]
165+
['id' => 1, 'title' => 'a title'],
166+
['id' => 2, 'title' => 'another title']
167167
];
168168
$this->assertSame($expected, $results);
169169

170170
$results = $table->find('all')->select(['id', 'foo' => 'title'])->toArray();
171171
$expected = [
172-
['things' => ['id' => 1, 'foo' => 'a title']],
173-
['things' => ['id' => 2, 'foo' => 'another title']]
172+
['id' => 1, 'foo' => 'a title'],
173+
['id' => 2, 'foo' => 'another title']
174174
];
175175
$this->assertSame($expected, $results);
176176
}
@@ -182,14 +182,14 @@ public function testFindAllConditionAutoTypes() {
182182
->select(['id', 'name'])
183183
->where(['posted >=' => new \DateTime('2012-12-22 12:01')]);
184184
$expected = [
185-
['dates' => ['id' => 3, 'name' => 'Jet Li']]
185+
['id' => 3, 'name' => 'Jet Li']
186186
];
187187
$this->assertSame($expected, $query->toArray());
188188

189189
$query->orWhere(['dates.posted' => new \DateTime('2012-12-22 12:00')]);
190190
$expected = [
191-
['dates' => ['id' => 2, 'name' => 'Bruce Lee']],
192-
['dates' => ['id' => 3, 'name' => 'Jet Li']]
191+
['id' => 2, 'name' => 'Bruce Lee'],
192+
['id' => 3, 'name' => 'Jet Li']
193193
];
194194
$this->assertSame($expected, $query->toArray());
195195
}

0 commit comments

Comments
 (0)