Skip to content

Commit fe88876

Browse files
authored
Merge pull request #197 from Kharhamel/fix/rightJoinBug
fixed a bug when doing a right join
2 parents 8db6c91 + 7ccde71 commit fe88876

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/InnerResultArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private function toIndex($offset): void
102102
}
103103
}
104104

105-
public function next()
105+
public function next(): void
106106
{
107107
// Let's overload the next() method to store the result.
108108
if (isset($this->results[$this->key + 1])) {

src/InnerResultIterator.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,21 @@ public function key()
160160
* Advances the cursor to the next result.
161161
* Casts the database result into one (or several) beans.
162162
*/
163-
public function next()
163+
public function next(): void
164164
{
165165
$row = $this->statement->fetch(\PDO::FETCH_ASSOC);
166166
if ($row) {
167167

168168
// array<tablegroup, array<table, array<column, value>>>
169169
$beansData = [];
170+
$allNull = true;
170171
foreach ($row as $key => $value) {
171172
if (!isset($this->columnDescriptors[$key])) {
172173
continue;
173174
}
175+
if ($allNull !== false && $value !== null) {
176+
$allNull = false;
177+
}
174178

175179
$columnDescriptor = $this->columnDescriptors[$key];
176180

@@ -184,6 +188,10 @@ public function next()
184188

185189
$beansData[$columnDescriptor['tableGroup']][$columnDescriptor['table']][$columnDescriptor['column']] = $value;
186190
}
191+
if ($allNull === true) {
192+
$this->next();
193+
return;
194+
}
187195

188196
$reflectionClassCache = [];
189197
$firstBean = true;

0 commit comments

Comments
 (0)