@@ -1477,6 +1477,53 @@ public function testSpatialQueryCombinations(): void
14771477 }
14781478 }
14791479
1480+ public function testSpatialIsNullIsNotNull (): void
1481+ {
1482+ /** @var Database $database */
1483+ $ database = $ this ->getDatabase ();
1484+ if (!$ database ->getAdapter ()->getSupportForSpatialAttributes ()) {
1485+ $ this ->expectNotToPerformAssertions ();
1486+ return ;
1487+ }
1488+
1489+ $ collectionName = 'spatial_null_checks ' ;
1490+ try {
1491+ $ database ->createCollection ($ collectionName );
1492+
1493+ $ this ->assertEquals (true , $ database ->createAttribute ($ collectionName , 'name ' , Database::VAR_STRING , 255 , true ));
1494+ // Optional spatial attribute: some documents legitimately have no location set.
1495+ $ this ->assertEquals (true , $ database ->createAttribute ($ collectionName , 'location ' , Database::VAR_POINT , 0 , false ));
1496+
1497+ $ database ->createDocument ($ collectionName , new Document ([
1498+ '$id ' => 'withLocation ' ,
1499+ 'name ' => 'Has a location ' ,
1500+ 'location ' => [40.7829 , -73.9654 ],
1501+ '$permissions ' => [Permission::read (Role::any ())],
1502+ ]));
1503+
1504+ $ database ->createDocument ($ collectionName , new Document ([
1505+ '$id ' => 'withoutLocation ' ,
1506+ 'name ' => 'No location set ' ,
1507+ 'location ' => null ,
1508+ '$permissions ' => [Permission::read (Role::any ())],
1509+ ]));
1510+
1511+ $ withLocation = $ database ->find ($ collectionName , [
1512+ Query::isNotNull ('location ' ),
1513+ ], Database::PERMISSION_READ );
1514+ $ this ->assertCount (1 , $ withLocation );
1515+ $ this ->assertEquals ('withLocation ' , $ withLocation [0 ]->getId ());
1516+
1517+ $ withoutLocation = $ database ->find ($ collectionName , [
1518+ Query::isNull ('location ' ),
1519+ ], Database::PERMISSION_READ );
1520+ $ this ->assertCount (1 , $ withoutLocation );
1521+ $ this ->assertEquals ('withoutLocation ' , $ withoutLocation [0 ]->getId ());
1522+ } finally {
1523+ $ database ->deleteCollection ($ collectionName );
1524+ }
1525+ }
1526+
14801527 public function testSpatialBulkOperation (): void
14811528 {
14821529 /** @var Database $database */
0 commit comments