Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Fix Invalid text representation: invalid input syntax for uuid: "0" with Postgres and BelongsTo #14005

Merged
merged 1 commit into from
Jun 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function getEagerModelKeys(array $models)
// null or 0 in (depending on if incrementing keys are in use) so the query wont
// fail plus returns zero results, which should be what the developer expects.
if (count($keys) === 0) {
return [$this->related->incrementing ? 0 : null];
return [$this->related->getIncrementing() ? 0 : null];
}

return array_values(array_unique($keys));
Expand Down
1 change: 1 addition & 0 deletions tests/Database/DatabaseEloquentBelongsToTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ protected function getRelation($parent = null, $incrementing = true)
$builder->shouldReceive('where')->with('relation.id', '=', 'foreign.value');
$related = m::mock('Illuminate\Database\Eloquent\Model');
$related->incrementing = $incrementing;
$related->shouldReceive('getIncrementing')->andReturn($incrementing);
$related->shouldReceive('getKeyName')->andReturn('id');
$related->shouldReceive('getTable')->andReturn('relation');
$builder->shouldReceive('getModel')->andReturn($related);
Expand Down