@@ -627,6 +627,72 @@ public function it_finds_partial_docs()
627627 ], $ result [$ docCId ]);
628628 }
629629
630+ /**
631+ * @test
632+ */
633+ public function it_gets_partial_doc_by_id ()
634+ {
635+ $ collectionName = 'test_get_partial_doc ' ;
636+ $ this ->documentStore ->addCollection ($ collectionName );
637+
638+ $ docAId = Uuid::uuid4 ()->toString ();
639+ $ docA = [
640+ 'some ' => [
641+ 'prop ' => 'foo ' ,
642+ 'other ' => [
643+ 'nested ' => 42
644+ ]
645+ ],
646+ 'baz ' => 'bat ' ,
647+ ];
648+ $ this ->documentStore ->addDoc ($ collectionName , $ docAId , $ docA );
649+
650+ $ docBId = Uuid::uuid4 ()->toString ();
651+ $ docB = [
652+ 'some ' => [
653+ 'prop ' => 'bar ' ,
654+ 'other ' => [
655+ 'nested ' => 43
656+ ],
657+ //'baz' => 'bat', missing so should be null
658+ ],
659+ ];
660+ $ this ->documentStore ->addDoc ($ collectionName , $ docBId , $ docB );
661+
662+ $ docCId = Uuid::uuid4 ()->toString ();
663+ $ docC = [
664+ 'some ' => [
665+ 'prop ' => 'foo ' ,
666+ 'other ' => [
667+ //'nested' => 42, missing, so should be null
668+ 'ignoredNested ' => 'value '
669+ ]
670+ ],
671+ 'baz ' => 'bat ' ,
672+ ];
673+ $ this ->documentStore ->addDoc ($ collectionName , $ docCId , $ docC );
674+
675+ $ partialSelect = new PartialSelect ([
676+ 'some.alias ' => 'some.prop ' , // Nested alias <- Nested field
677+ 'magicNumber ' => 'some.other.nested ' , // Top level alias <- Nested Field
678+ 'baz ' , // Top level field,
679+ ]);
680+
681+ $ partialDocA = $ this ->documentStore ->getPartialDoc ($ collectionName , $ partialSelect , $ docAId );
682+
683+ $ this ->assertEquals ([
684+ 'some ' => [
685+ 'alias ' => 'foo ' ,
686+ ],
687+ 'magicNumber ' => 42 ,
688+ 'baz ' => 'bat ' ,
689+ ], $ partialDocA );
690+
691+ $ partialDocD = $ this ->documentStore ->getPartialDoc ($ collectionName , $ partialSelect , Uuid::uuid4 ()->toString ());
692+
693+ $ this ->assertNull ($ partialDocD );
694+ }
695+
630696 /**
631697 * @test
632698 */
0 commit comments