Unverified Commit f3f230a9 authored by Jens Segers's avatar Jens Segers Committed by GitHub

Merge pull request #1740 from jim5359/EmbedsMany-primaryKey-fix

EmbedsMany respect primaryKey on association
parents 069b233b 4ae4a7c6
...@@ -227,7 +227,7 @@ class EmbedsMany extends EmbedsOneOrMany ...@@ -227,7 +227,7 @@ class EmbedsMany extends EmbedsOneOrMany
protected function associateNew($model) protected function associateNew($model)
{ {
// Create a new key if needed. // Create a new key if needed.
if (!$model->getAttribute('_id')) { if ($model->getKeyName() === '_id' && !$model->getAttribute('_id')) {
$model->setAttribute('_id', new ObjectID); $model->setAttribute('_id', new ObjectID);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment