@@ -1950,63 +1950,63 @@ public function testPartialUpdateManyToManyBothSides(): void
19501950 return ;
19511951 }
19521952
1953- $ database ->createCollection ('students ' );
1954- $ database ->createCollection ('courses ' );
1953+ $ database ->createCollection ('partial_students ' );
1954+ $ database ->createCollection ('partial_courses ' );
19551955
1956- $ database ->createAttribute ('students ' , 'name ' , Database::VAR_STRING , 255 , true );
1957- $ database ->createAttribute ('students ' , 'grade ' , Database::VAR_STRING , 10 , false );
1958- $ database ->createAttribute ('courses ' , 'title ' , Database::VAR_STRING , 255 , true );
1959- $ database ->createAttribute ('courses ' , 'credits ' , Database::VAR_INTEGER , 0 , false );
1956+ $ database ->createAttribute ('partial_students ' , 'name ' , Database::VAR_STRING , 255 , true );
1957+ $ database ->createAttribute ('partial_students ' , 'grade ' , Database::VAR_STRING , 10 , false );
1958+ $ database ->createAttribute ('partial_courses ' , 'title ' , Database::VAR_STRING , 255 , true );
1959+ $ database ->createAttribute ('partial_courses ' , 'credits ' , Database::VAR_INTEGER , 0 , false );
19601960
19611961 $ database ->createRelationship (
1962- collection: 'students ' ,
1963- relatedCollection: 'courses ' ,
1962+ collection: 'partial_students ' ,
1963+ relatedCollection: 'partial_courses ' ,
19641964 type: Database::RELATION_MANY_TO_MANY ,
19651965 twoWay: true ,
1966- id: 'courses ' ,
1967- twoWayKey: 'students '
1966+ id: 'partial_courses ' ,
1967+ twoWayKey: 'partial_students '
19681968 );
19691969
19701970 // Create student with courses
1971- $ database ->createDocument ('students ' , new Document ([
1971+ $ database ->createDocument ('partial_students ' , new Document ([
19721972 '$id ' => 'student1 ' ,
19731973 '$permissions ' => [Permission::read (Role::any ()), Permission::update (Role::any ())],
19741974 'name ' => 'David ' ,
19751975 'grade ' => 'A ' ,
1976- 'courses ' => [
1976+ 'partial_courses ' => [
19771977 ['$id ' => 'course1 ' , '$permissions ' => [Permission::read (Role::any ()), Permission::update (Role::any ())], 'title ' => 'Math ' , 'credits ' => 3 ],
19781978 ['$id ' => 'course2 ' , '$permissions ' => [Permission::read (Role::any ()), Permission::update (Role::any ())], 'title ' => 'Science ' , 'credits ' => 4 ],
19791979 ],
19801980 ]));
19811981
19821982 // Partial update from student side - update grade only, preserve courses
1983- $ database ->updateDocument ('students ' , 'student1 ' , new Document ([
1983+ $ database ->updateDocument ('partial_students ' , 'student1 ' , new Document ([
19841984 '$id ' => 'student1 ' ,
1985- '$collection ' => 'students ' ,
1985+ '$collection ' => 'partial_students ' ,
19861986 'grade ' => 'A+ ' ,
19871987 '$permissions ' => [Permission::read (Role::any ()), Permission::update (Role::any ())],
19881988 ]));
19891989
1990- $ student = $ database ->getDocument ('students ' , 'student1 ' );
1990+ $ student = $ database ->getDocument ('partial_students ' , 'student1 ' );
19911991 $ this ->assertEquals ('David ' , $ student ->getAttribute ('name ' ), 'Name should be preserved ' );
19921992 $ this ->assertEquals ('A+ ' , $ student ->getAttribute ('grade ' ), 'Grade should be updated ' );
1993- $ this ->assertCount (2 , $ student ->getAttribute ('courses ' ), 'Courses should be preserved ' );
1993+ $ this ->assertCount (2 , $ student ->getAttribute ('partial_courses ' ), 'Courses should be preserved ' );
19941994
19951995 // Partial update from course side - update credits only, preserve students
1996- $ database ->updateDocument ('courses ' , 'course1 ' , new Document ([
1996+ $ database ->updateDocument ('partial_courses ' , 'course1 ' , new Document ([
19971997 '$id ' => 'course1 ' ,
1998- '$collection ' => 'courses ' ,
1998+ '$collection ' => 'partial_courses ' ,
19991999 'credits ' => 5 ,
20002000 '$permissions ' => [Permission::read (Role::any ()), Permission::update (Role::any ())],
20012001 ]));
20022002
2003- $ course = $ database ->getDocument ('courses ' , 'course1 ' );
2003+ $ course = $ database ->getDocument ('partial_courses ' , 'course1 ' );
20042004 $ this ->assertEquals ('Math ' , $ course ->getAttribute ('title ' ), 'Title should be preserved ' );
20052005 $ this ->assertEquals (5 , $ course ->getAttribute ('credits ' ), 'Credits should be updated ' );
2006- $ this ->assertCount (1 , $ course ->getAttribute ('students ' ), 'Students should be preserved ' );
2006+ $ this ->assertCount (1 , $ course ->getAttribute ('partial_students ' ), 'Students should be preserved ' );
20072007
2008- $ database ->deleteCollection ('students ' );
2009- $ database ->deleteCollection ('courses ' );
2008+ $ database ->deleteCollection ('partial_students ' );
2009+ $ database ->deleteCollection ('partial_courses ' );
20102010 }
20112011
20122012 public function testPartialUpdateManyToManyWithStringIdsAndDocuments (): void
0 commit comments