Skip to content

Commit 476aef4

Browse files
abnegateclaude
andcommitted
fix: align spatial method signatures, fix import ordering
- Add $type parameter to Postgres handleSpatialQueries/handleDistanceSpatialQueries to match SQL.php parent signatures - Fix import ordering in SQL.php, remove unused import in Postgres Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5a53446 commit 476aef4

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/Database/Adapter/Postgres.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
use Utopia\Database\Operator;
2727
use Utopia\Database\OperatorType;
2828
use Utopia\Database\Query;
29-
use Utopia\Database\Relationship;
3029
use Utopia\Database\RelationSide;
3130
use Utopia\Database\RelationType;
3231
use Utopia\Query\Builder\PostgreSQL as PostgreSQLBuilder;
@@ -1427,7 +1426,7 @@ protected function getOperatorUpsertExpression(string $column, Operator $operato
14271426
*
14281427
* @param array<string, mixed> $binds
14291428
*/
1430-
protected function handleDistanceSpatialQueries(Query $query, array &$binds, string $attribute, string $alias, string $placeholder): string
1429+
protected function handleDistanceSpatialQueries(Query $query, array &$binds, string $attribute, string $type, string $alias, string $placeholder): string
14311430
{
14321431
/** @var array<mixed> $distanceParams */
14331432
$distanceParams = $query->getValues()[0];
@@ -1461,7 +1460,7 @@ protected function handleDistanceSpatialQueries(Query $query, array &$binds, str
14611460
*
14621461
* @param array<string, mixed> $binds
14631462
*/
1464-
protected function handleSpatialQueries(Query $query, array &$binds, string $attribute, string $alias, string $placeholder): string
1463+
protected function handleSpatialQueries(Query $query, array &$binds, string $attribute, string $type, string $alias, string $placeholder): string
14651464
{
14661465
$spatialGeomRaw = $query->getValues()[0];
14671466
$binds[":{$placeholder}_0"] = $this->convertArrayToWKT(\is_array($spatialGeomRaw) ? $spatialGeomRaw : []);
@@ -1473,7 +1472,7 @@ protected function handleSpatialQueries(Query $query, array &$binds, string $att
14731472
Method::DistanceEqual,
14741473
Method::DistanceNotEqual,
14751474
Method::DistanceGreaterThan,
1476-
Method::DistanceLessThan => $this->handleDistanceSpatialQueries($query, $binds, $attribute, $alias, $placeholder),
1475+
Method::DistanceLessThan => $this->handleDistanceSpatialQueries($query, $binds, $attribute, $type, $alias, $placeholder),
14771476
Method::Equal => "ST_Equals({$alias}.{$attribute}, {$geom})",
14781477
Method::NotEqual => "NOT ST_Equals({$alias}.{$attribute}, {$geom})",
14791478
Method::Intersects => "ST_Intersects({$alias}.{$attribute}, {$geom})",
@@ -1567,7 +1566,7 @@ protected function getSQLCondition(Query $query, array &$binds): string
15671566
$operator = null;
15681567

15691568
if ($query->isSpatialAttribute()) {
1570-
return $this->handleSpatialQueries($query, $binds, $attribute, $alias, $placeholder);
1569+
return $this->handleSpatialQueries($query, $binds, $attribute, $query->getAttributeType(), $alias, $placeholder);
15711570
}
15721571

15731572
if ($query->isObjectAttribute() && ! $isNestedObjectAttribute) {

src/Database/Adapter/SQL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
use Utopia\Database\Relationship;
3838
use Utopia\Database\RelationSide;
3939
use Utopia\Database\RelationType;
40-
use Utopia\Query\Schema\MySQL as MySQLSchema;
4140
use Utopia\Query\Builder\BuildResult;
4241
use Utopia\Query\Builder\SQL as SQLBuilder;
4342
use Utopia\Query\CursorDirection;
@@ -51,6 +50,7 @@
5150
use Utopia\Query\Schema\Column;
5251
use Utopia\Query\Schema\ColumnType;
5352
use Utopia\Query\Schema\IndexType;
53+
use Utopia\Query\Schema\MySQL as MySQLSchema;
5454

5555
/**
5656
* Abstract base adapter for SQL-based database engines (MariaDB, MySQL, PostgreSQL, SQLite).

0 commit comments

Comments
 (0)