Closed
Description
I have a situation where I don't want my EmbedMany objects to have an _id attribute. Normally I can just set the $primaryKey = null on my object. But EmbedMany is not respecting this on new associations. I've identified the code that should be changed:
/Relations/EmbedsMany.php
Currently:
protected function associateNew($model)
{
// Create a new key if needed.
if (!$model->getAttribute('_id')) {
$model->setAttribute('_id', new ObjectID);
}
...
Should Be:
protected function associateNew($model)
{
// Create a new key if needed.
if ($model->getKeyName() == '_id' && !$model->getAttribute('_id')) {
$model->setAttribute('_id', new ObjectID);
}
...