Skip to content

Overriding $primaryKey does not work with find($id) #1354

Closed
@jim5359

Description

@jim5359

I get the error:
Undefined index: myId in /Jenssegers/Mongodb/Query/Builder.php:575

It looks like the Builder class is hard-coded to expect the key as _id:

return $sequence == '_id' ? $result->getInsertedId() : $values[$sequence];

This causes problems when doing a find($id) when you've modified the primaryKey to be something else in the model class.

public $primaryKey = 'myId';

I'm using the latest master version using PHP7 and Mongo 3.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions