diff --git a/src/Database/Adapter/Mongo.php b/src/Database/Adapter/Mongo.php index 52acc9541..159eec72a 100644 --- a/src/Database/Adapter/Mongo.php +++ b/src/Database/Adapter/Mongo.php @@ -1244,7 +1244,8 @@ public function createDocument(Document $collection, Document $document): Docume $record['_id'] = $sequence; } $options = $this->getTransactionOptions(); - $result = $this->insertDocument($name, $this->removeNullKeys($record), $options); + //$record = $this->removeNullKeys($record); + $result = $this->insertDocument($name, $record, $options); $result = $this->replaceChars('_', '$', $result); // in order to keep the original object refrence. foreach ($result as $key => $value) { diff --git a/tests/e2e/Adapter/Scopes/DocumentTests.php b/tests/e2e/Adapter/Scopes/DocumentTests.php index e79e9ccec..e51ccaf0b 100644 --- a/tests/e2e/Adapter/Scopes/DocumentTests.php +++ b/tests/e2e/Adapter/Scopes/DocumentTests.php @@ -231,7 +231,7 @@ public function testCreateDocument(): Document $this->assertEquals(['pink', 'green', 'blue'], $manualIdDocument->getAttribute('colors')); $this->assertEquals([], $manualIdDocument->getAttribute('empty')); $this->assertEquals('Works', $manualIdDocument->getAttribute('with-dash')); - $this->assertEquals(null, $manualIdDocument->getAttribute('id')); + $this->assertEquals(null, $manualIdDocument->getAttribute('always_null')); $manualIdDocument = $database->getDocument('documents', '56000'); @@ -345,10 +345,15 @@ public function testCreateDocument(): Document ])); $this->assertNotEmpty($documentIdNull->getSequence()); $this->assertNull($documentIdNull->getAttribute('id')); + $this->assertNull($documentIdNull['id']); + $this->assertTrue($documentIdNull->offsetExists('id')); $documentIdNull = $database->getDocument('documents', $documentIdNull->getId()); + $this->assertNotEmpty($documentIdNull->getId()); $this->assertNull($documentIdNull->getAttribute('id')); + $this->assertNull($documentIdNull['id']); + $this->assertTrue($documentIdNull->offsetExists('id')); $documentIdNull = $database->findOne('documents', [ query::isNull('id')