Skip to content

Commit e23241d

Browse files
committed
Hide MongoId and MongoDate objects from the user
1 parent f5ffbfb commit e23241d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Jenssegers/Mongodb/Builder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ public function insertGetId(array $values, $sequence = null)
260260

261261
if (1 == (int) $result['ok'])
262262
{
263-
return $values['_id'];
263+
// Return id as a string
264+
return (string) $values['_id'];
264265
}
265266
}
266267

tests/ModelTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ public function testInsert()
3737
$user->name = "John Doe";
3838
$user->title = "admin";
3939
$user->age = 35;
40+
4041
$user->save();
4142

4243
$this->assertEquals(true, $user->exists);
4344
$this->assertEquals(1, User::count());
4445

45-
$this->assertInstanceOf('MongoId', $user->_id);
46+
$this->assertTrue(isset($user->_id));
4647
$this->assertNotEquals('', (string) $user->_id);
4748
$this->assertNotEquals(0, strlen((string) $user->_id));
4849
$this->assertInstanceOf('DateTime', $user->created_at);

0 commit comments

Comments
 (0)