@@ -840,6 +840,53 @@ public function testSpatialIndex(): void
840840 } finally {
841841 $ database ->deleteCollection ($ collNullIndex );
842842 }
843+
844+ $ collUpdateNull = 'spatial_idx_update_null_ ' . uniqid ();
845+ try {
846+ $ database ->createCollection ($ collUpdateNull );
847+
848+ $ database ->createAttribute ($ collUpdateNull , 'loc ' , Database::VAR_POINT , 0 , false );
849+ if (!$ nullSupported ) {
850+ try {
851+ $ database ->createIndex ($ collUpdateNull , 'idx_loc ' , Database::INDEX_SPATIAL , ['loc ' ]);
852+ $ this ->fail ('Expected exception when creating spatial index on NULL-able attribute ' );
853+ } catch (\Throwable $ e ) {
854+ $ this ->assertInstanceOf (Exception::class, $ e );
855+ }
856+ } else {
857+ $ this ->assertTrue ($ database ->createIndex ($ collUpdateNull , 'idx_loc ' , Database::INDEX_SPATIAL , ['loc ' ]));
858+ }
859+
860+ $ database ->updateAttribute ($ collUpdateNull , 'loc ' , required: true );
861+
862+ $ this ->assertTrue ($ database ->createIndex ($ collUpdateNull , 'idx_loc_req ' , Database::INDEX_SPATIAL , ['loc ' ]));
863+ } finally {
864+ $ database ->deleteCollection ($ collUpdateNull );
865+ }
866+
867+
868+ $ collUpdateNull = 'spatial_idx_index_null_ ' . uniqid ();
869+ try {
870+ $ database ->createCollection ($ collUpdateNull );
871+
872+ $ database ->createAttribute ($ collUpdateNull , 'loc ' , Database::VAR_POINT , 0 , false );
873+ if (!$ nullSupported ) {
874+ try {
875+ $ database ->createIndex ($ collUpdateNull , 'idx_loc ' , Database::INDEX_SPATIAL , ['loc ' ]);
876+ $ this ->fail ('Expected exception when creating spatial index on NULL-able attribute ' );
877+ } catch (\Throwable $ e ) {
878+ $ this ->assertInstanceOf (Exception::class, $ e );
879+ }
880+ } else {
881+ $ this ->assertTrue ($ database ->createIndex ($ collUpdateNull , 'idx_loc ' , Database::INDEX_SPATIAL , ['loc ' ]));
882+ }
883+
884+ $ database ->updateAttribute ($ collUpdateNull , 'loc ' , required: true );
885+
886+ $ this ->assertTrue ($ database ->createIndex ($ collUpdateNull , 'idx_loc_req ' , Database::INDEX_SPATIAL , ['loc ' ]));
887+ } finally {
888+ $ database ->deleteCollection ($ collUpdateNull );
889+ }
843890 }
844891
845892 public function testComplexGeometricShapes (): void
0 commit comments