@@ -295,8 +295,8 @@ public function testMultipleConditionsAcrossCollectionsProduceAndClause(): void
295295 $ mapper = $ this ->mapper ;
296296 $ comment = $ mapper ->comment [7 ]->post [5 ]->fetch ();
297297 $ this ->assertEquals (7 , $ comment ->id );
298- $ this ->assertEquals (5 , $ comment ->post_id ->id );
299- $ this ->assertEquals ('Post Title ' , $ comment ->post_id ->title );
298+ $ this ->assertEquals (5 , $ comment ->post ->id );
299+ $ this ->assertEquals ('Post Title ' , $ comment ->post ->title );
300300 }
301301
302302 public function testNestedCollectionsShouldHydrateResults (): void
@@ -305,11 +305,11 @@ public function testNestedCollectionsShouldHydrateResults(): void
305305 $ comment = $ mapper ->comment ->post [5 ]->fetch ();
306306 $ this ->assertEquals (7 , $ comment ->id );
307307 $ this ->assertEquals ('Comment Text ' , $ comment ->text );
308- $ this ->assertEquals (4 , count (get_object_vars ($ comment )));
309- $ this ->assertEquals (5 , $ comment ->post_id ->id );
310- $ this ->assertEquals ('Post Title ' , $ comment ->post_id ->title );
311- $ this ->assertEquals ('Post Text ' , $ comment ->post_id ->text );
312- $ this ->assertEquals (4 , count (get_object_vars ($ comment ->post_id )));
308+ $ this ->assertEquals (5 , count (get_object_vars ($ comment )));
309+ $ this ->assertEquals (5 , $ comment ->post ->id );
310+ $ this ->assertEquals ('Post Title ' , $ comment ->post ->title );
311+ $ this ->assertEquals ('Post Text ' , $ comment ->post ->text );
312+ $ this ->assertEquals (4 , count (get_object_vars ($ comment ->post )));
313313 }
314314
315315 public function testOneToN (): void
@@ -320,14 +320,14 @@ public function testOneToN(): void
320320 $ this ->assertEquals (1 , count ($ comments ));
321321 $ this ->assertEquals (7 , $ comment ->id );
322322 $ this ->assertEquals ('Comment Text ' , $ comment ->text );
323- $ this ->assertEquals (4 , count (get_object_vars ($ comment )));
324- $ this ->assertEquals (5 , $ comment ->post_id ->id );
325- $ this ->assertEquals ('Post Title ' , $ comment ->post_id ->title );
326- $ this ->assertEquals ('Post Text ' , $ comment ->post_id ->text );
327- $ this ->assertEquals (4 , count (get_object_vars ($ comment ->post_id )));
328- $ this ->assertEquals (1 , $ comment ->post_id -> author_id ->id );
329- $ this ->assertEquals ('Author 1 ' , $ comment ->post_id -> author_id ->name );
330- $ this ->assertEquals (2 , count (get_object_vars ($ comment ->post_id -> author_id )));
323+ $ this ->assertEquals (5 , count (get_object_vars ($ comment )));
324+ $ this ->assertEquals (5 , $ comment ->post ->id );
325+ $ this ->assertEquals ('Post Title ' , $ comment ->post ->title );
326+ $ this ->assertEquals ('Post Text ' , $ comment ->post ->text );
327+ $ this ->assertEquals (5 , count (get_object_vars ($ comment ->post )));
328+ $ this ->assertEquals (1 , $ comment ->post -> author ->id );
329+ $ this ->assertEquals ('Author 1 ' , $ comment ->post -> author ->name );
330+ $ this ->assertEquals (2 , count (get_object_vars ($ comment ->post -> author )));
331331 }
332332
333333 public function testNtoN (): void
@@ -338,11 +338,11 @@ public function testNtoN(): void
338338 $ this ->assertEquals (1 , count ($ comments ));
339339 $ this ->assertEquals (7 , $ comment ->id );
340340 $ this ->assertEquals ('Comment Text ' , $ comment ->text );
341- $ this ->assertEquals (4 , count (get_object_vars ($ comment )));
342- $ this ->assertEquals (5 , $ comment ->post_id ->id );
343- $ this ->assertEquals ('Post Title ' , $ comment ->post_id ->title );
344- $ this ->assertEquals ('Post Text ' , $ comment ->post_id ->text );
345- $ this ->assertEquals (4 , count (get_object_vars ($ comment ->post_id )));
341+ $ this ->assertEquals (5 , count (get_object_vars ($ comment )));
342+ $ this ->assertEquals (5 , $ comment ->post ->id );
343+ $ this ->assertEquals ('Post Title ' , $ comment ->post ->title );
344+ $ this ->assertEquals ('Post Text ' , $ comment ->post ->text );
345+ $ this ->assertEquals (4 , count (get_object_vars ($ comment ->post )));
346346 }
347347
348348 public function testManyToManyReverse (): void
@@ -557,7 +557,7 @@ public function testFetchingAllEntityTypedNested(): void
557557 $ mapper = new Mapper ($ this ->conn , new EntityFactory (entityNamespace: '\Respect\Relational \\' ));
558558 $ comment = $ mapper ->comment ->post ->fetchAll ();
559559 $ this ->assertInstanceOf ('\Respect\Relational\Comment ' , $ comment [0 ]);
560- $ this ->assertInstanceOf ('\Respect\Relational\Post ' , $ comment [0 ]->post_id );
560+ $ this ->assertInstanceOf ('\Respect\Relational\Post ' , $ comment [0 ]->post );
561561 }
562562
563563 public function testPersistingEntityTyped (): void
@@ -699,10 +699,10 @@ public function testFilteredCollectionsShouldHydrateNonFilteredPartsAsUsual(): v
699699 $ mapper ->postsFromAuthorsWithComments = Filtered::comment ()->post ()->author ();
700700 $ post = $ mapper ->postsFromAuthorsWithComments ->fetch ();
701701 $ this ->assertEquals (
702- (object ) (['author_id ' => $ post ->author_id ] + (array ) $ this ->posts [0 ]),
702+ (object ) (['author ' => $ post ->author ] + (array ) $ this ->posts [0 ]),
703703 $ post ,
704704 );
705- $ this ->assertEquals ($ this ->authors [0 ], $ post ->author_id );
705+ $ this ->assertEquals ($ this ->authors [0 ], $ post ->author );
706706 }
707707
708708 public function testFilteredCollectionsShouldPersistHydratedNonFilteredPartsAsUsual (): void
@@ -711,12 +711,12 @@ public function testFilteredCollectionsShouldPersistHydratedNonFilteredPartsAsUs
711711 $ mapper ->postsFromAuthorsWithComments = Filtered::comment ()->post ()->author ();
712712 $ post = $ mapper ->postsFromAuthorsWithComments ->fetch ();
713713 $ this ->assertEquals (
714- (object ) (['author_id ' => $ post ->author_id ] + (array ) $ this ->posts [0 ]),
714+ (object ) (['author ' => $ post ->author ] + (array ) $ this ->posts [0 ]),
715715 $ post ,
716716 );
717- $ this ->assertEquals ($ this ->authors [0 ], $ post ->author_id );
717+ $ this ->assertEquals ($ this ->authors [0 ], $ post ->author );
718718 $ post ->title = 'Title Changed ' ;
719- $ post ->author_id ->name = 'John ' ;
719+ $ post ->author ->name = 'John ' ;
720720 $ mapper ->postsFromAuthorsWithComments ->persist ($ post );
721721 $ mapper ->flush ();
722722 $ result = $ this ->query ('select title from post where id=5 ' )
@@ -904,14 +904,15 @@ public function testFetchingRegisteredFilteredCollectionsAlongsideNormal(): void
904904 $ post = $ mapper ->post ->fetchAll ();
905905 $ post = $ post [0 ];
906906 $ this ->assertEquals (
907- (object ) ['id ' => '5 ' , 'author_id ' => $ post ->author_id ],
907+ (object ) ['id ' => '5 ' , 'author_id ' => 1 , ' author ' => $ post ->author ],
908908 $ post ,
909909 );
910910 $ this ->assertEquals (
911911 (object ) ['name ' => 'Author 1 ' , 'id ' => 1 ],
912- $ post ->author_id ,
912+ $ post ->author ,
913913 );
914914 $ post ->title = 'Title Changed ' ;
915+
915916 $ mapper ->postsFromAuthorsWithComments ->persist ($ post );
916917 $ mapper ->flush ();
917918 $ result = $ this ->query ('select title from post where id=5 ' )
@@ -926,12 +927,13 @@ public function testCompositesBringResultsFromTwoTables(): void
926927 $ post = $ mapper ->postComment ->fetch ();
927928 $ this ->assertEquals (
928929 (object ) ['name ' => 'Author 1 ' , 'id ' => 1 ],
929- $ post ->author_id ,
930+ $ post ->author ,
930931 );
931932 $ this ->assertEquals (
932933 (object ) [
933934 'id ' => '5 ' ,
934- 'author_id ' => $ post ->author_id ,
935+ 'author_id ' => 1 ,
936+ 'author ' => $ post ->author ,
935937 'text ' => 'Comment Text ' ,
936938 'title ' => 'Post Title ' ,
937939 'comment_id ' => 7 ,
@@ -947,12 +949,13 @@ public function testCompositesPersistsResultsOnTwoTables(): void
947949 $ post = $ mapper ->postComment ->fetch ();
948950 $ this ->assertEquals (
949951 (object ) ['name ' => 'Author 1 ' , 'id ' => 1 ],
950- $ post ->author_id ,
952+ $ post ->author ,
951953 );
952954 $ this ->assertEquals (
953955 (object ) [
954956 'id ' => '5 ' ,
955- 'author_id ' => $ post ->author_id ,
957+ 'author_id ' => 1 ,
958+ 'author ' => $ post ->author ,
956959 'text ' => 'Comment Text ' ,
957960 'title ' => 'Post Title ' ,
958961 'comment_id ' => 7 ,
@@ -961,6 +964,7 @@ public function testCompositesPersistsResultsOnTwoTables(): void
961964 );
962965 $ post ->title = 'Title Changed ' ;
963966 $ post ->text = 'Comment Changed ' ;
967+
964968 $ mapper ->postsFromAuthorsWithComments ->persist ($ post );
965969 $ mapper ->flush ();
966970 $ result = $ this ->query ('select title from post where id=5 ' )
@@ -997,6 +1001,7 @@ public function testCompositesPersistDoesNotDropColumnsWithMatchingValues(): voi
9971001 $ post = $ mapper ->postComment ->fetch ();
9981002 $ post ->title = 'Same Value ' ;
9991003 $ post ->text = 'Same Value ' ;
1004+
10001005 $ mapper ->postComment ->persist ($ post );
10011006 $ mapper ->flush ();
10021007 $ result = $ this ->query ('select title from post where id=5 ' )
@@ -1015,12 +1020,13 @@ public function testCompositesAll(): void
10151020 $ post = $ post [0 ];
10161021 $ this ->assertEquals (
10171022 (object ) ['name ' => 'Author 1 ' , 'id ' => 1 ],
1018- $ post ->author_id ,
1023+ $ post ->author ,
10191024 );
10201025 $ this ->assertEquals (
10211026 (object ) [
10221027 'id ' => '5 ' ,
1023- 'author_id ' => $ post ->author_id ,
1028+ 'author_id ' => 1 ,
1029+ 'author ' => $ post ->author ,
10241030 'text ' => 'Comment Text ' ,
10251031 'title ' => 'Post Title ' ,
10261032 'comment_id ' => 7 ,
@@ -1029,6 +1035,7 @@ public function testCompositesAll(): void
10291035 );
10301036 $ post ->title = 'Title Changed ' ;
10311037 $ post ->text = 'Comment Changed ' ;
1038+
10321039 $ mapper ->postsFromAuthorsWithComments ->persist ($ post );
10331040 $ mapper ->flush ();
10341041 $ result = $ this ->query ('select title from post where id=5 ' )
0 commit comments