Skip to content

Commit 78ca0c7

Browse files
replaced database exception with query exception
1 parent 79e7eba commit 78ca0c7

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/Database/Adapter/MariaDB.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Utopia\Database\Exception as DatabaseException;
1010
use Utopia\Database\Exception\Duplicate as DuplicateException;
1111
use Utopia\Database\Exception\NotFound as NotFoundException;
12+
use Utopia\Database\Exception\Query as QueryException;
1213
use Utopia\Database\Exception\Timeout as TimeoutException;
1314
use Utopia\Database\Exception\Truncate as TruncateException;
1415
use Utopia\Database\Helpers\ID;
@@ -1393,7 +1394,7 @@ protected function handleDistanceSpatialQueries(Query $query, array &$binds, str
13931394
$wktType = $this->getSpatialTypeFromWKT($wkt);
13941395
$attrType = strtolower($type);
13951396
if ($wktType != Database::VAR_POINT || $attrType != Database::VAR_POINT) {
1396-
throw new DatabaseException('Distance in meters is not supported between '.$attrType . ' and '. $wktType);
1397+
throw new QueryException('Distance in meters is not supported between '.$attrType . ' and '. $wktType);
13971398
}
13981399
return "ST_DISTANCE_SPHERE({$alias}.{$attribute}, ST_GeomFromText(:{$placeholder}_0), 6371000) {$operator} :{$placeholder}_1";
13991400
}

tests/e2e/Adapter/Scopes/SpatialTests.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Utopia\Database\Database;
66
use Utopia\Database\Document;
77
use Utopia\Database\Exception;
8+
use Utopia\Database\Exception\Query as QueryException;
89
use Utopia\Database\Exception\Structure as StructureException;
910
use Utopia\Database\Helpers\ID;
1011
use Utopia\Database\Helpers\Permission;
@@ -2382,11 +2383,10 @@ public function testSpatialDistanceInMeterError(): void
23822383
]);
23832384
$this->fail('Expected Exception not thrown for ' . implode(' vs ', $case['expected']));
23842385
} catch (\Exception $e) {
2385-
$this->assertInstanceOf(\Exception::class, $e);
2386+
$this->assertInstanceOf(QueryException::class, $e);
23862387

23872388
// Validate exception message contains correct type names
23882389
$msg = strtolower($e->getMessage());
2389-
var_dump($msg);
23902390
$this->assertStringContainsString($case['expected'][0], $msg, 'Attr type missing in exception');
23912391
$this->assertStringContainsString($case['expected'][1], $msg, 'Geom type missing in exception');
23922392
}

0 commit comments

Comments
 (0)