Skip to content

Commit

Permalink
Merge pull request #28804 from staudenmeir/cursor
Browse files Browse the repository at this point in the history
[5.8] Set connection name on cursor() results
  • Loading branch information
taylorotwell authored Jun 11, 2019
2 parents d328708 + e19637e commit 1ca32c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ protected function isNestedUnder($relation, $name)
public function cursor()
{
foreach ($this->applyScopes()->query->cursor() as $record) {
yield $this->model->newFromBuilder($record);
yield $this->newModelInstance()->newFromBuilder($record);
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/Database/DatabaseEloquentIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public function testBasicModelRetrieval()
$models = EloquentTestUser::where('id', 1)->cursor();
foreach ($models as $model) {
$this->assertEquals(1, $model->id);
$this->assertEquals('default', $model->getConnectionName());
}

$records = DB::table('users')->where('id', 1)->cursor();
Expand Down

0 comments on commit 1ca32c0

Please sign in to comment.