Skip to content

Revert changes in Builder and Model for id keys, fix test for Queue #1795

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

Merged
merged 2 commits into from
Aug 1, 2019
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
4 changes: 2 additions & 2 deletions src/Jenssegers/Mongodb/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class Model extends BaseModel
* @var string
*/
protected $primaryKey = '_id';

/**
* The primary key type.
*
Expand Down Expand Up @@ -175,7 +175,7 @@ protected function getAttributeFromArray($key)
public function setAttribute($key, $value)
{
// Convert _id to ObjectID.
if (($key == '_id' || Str::endsWith($key, '_id')) && is_string($value)) {
if ($key == '_id' && is_string($value)) {
$builder = $this->newBaseQueryBuilder();

$value = $builder->convertKey($value);
Expand Down
2 changes: 1 addition & 1 deletion src/Jenssegers/Mongodb/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ protected function compileWheres()
}

// Convert id's.
if (isset($where['column']) && ($where['column'] == '_id' || Str::endsWith($where['column'], '_id'))) {
if (isset($where['column']) && ($where['column'] == '_id' || Str::endsWith($where['column'], '._id'))) {
// Multiple values.
if (isset($where['values'])) {
foreach ($where['values'] as &$value) {
Expand Down
1 change: 1 addition & 0 deletions tests/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function testQueueJobLifeCycle()
'displayName' => 'test',
'job' => 'test',
'maxTries' => null,
'delay' => null,
'timeout' => null,
'data' => ['action' => 'QueueJobLifeCycle'],
]), $job->getRawBody());
Expand Down