Commit de3ffe0d authored by Jens Segers's avatar Jens Segers

Dont set primaryKey to MongoId

parent ff6eb2db
...@@ -163,9 +163,9 @@ class EmbedsMany extends Relation { ...@@ -163,9 +163,9 @@ class EmbedsMany extends Relation {
protected function performInsert(Model $model) protected function performInsert(Model $model)
{ {
// Create a new key. // Create a new key.
if (!$model->getKey()) if (!isset($model['_id']))
{ {
$model->setAttribute($model->getKeyName(), new MongoId); $model->setAttribute('_id', new MongoId);
} }
// Set timestamps. // Set timestamps.
......
...@@ -292,6 +292,7 @@ class RelationsTest extends PHPUnit_Framework_TestCase { ...@@ -292,6 +292,7 @@ class RelationsTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(array('London'), $user->addresses->lists('city')); $this->assertEquals(array('London'), $user->addresses->lists('city'));
$this->assertInstanceOf('DateTime', $address->created_at); $this->assertInstanceOf('DateTime', $address->created_at);
$this->assertInstanceOf('DateTime', $address->updated_at); $this->assertInstanceOf('DateTime', $address->updated_at);
$this->assertNotNull($address->_id);
$address = $user->addresses()->save(new Address(array('city' => 'Paris'))); $address = $user->addresses()->save(new Address(array('city' => 'Paris')));
......
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