Skip to content

Commit 7cf2956

Browse files
authored
Merge pull request #44 from tarfin-labs/fix/distance-parameter-type-for-v2
fix/distance parameter type for v2.x
2 parents ed03da2 + cfa2b8d commit 7cf2956

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to `laravel-spatial` will be documented in this file
44

5+
## 2.2.1 - 2025-06-12
6+
- Fixed `$distance` parameter type from `int` to `float` in `scopeWithinDistanceTo` and related methods to properly handle decimal distance values returned by `ST_Distance` function.
7+
58
## 2.2.0 - 2025-05-15
69
- Expression support added to `get()` method in `LocationCast`.
710

src/Traits/HasSpatial.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function scopeSelectDistanceTo(Builder $query, string $column, Point $poi
2525
};
2626
}
2727

28-
public function scopeWithinDistanceTo(Builder $query, string $column, Point $point, int $distance): void
28+
public function scopeWithinDistanceTo(Builder $query, string $column, Point $point, float $distance): void
2929
{
3030
match (DB::connection()->getDriverName()) {
3131
'pgsql', 'mysql' => $this->withinDistanceToMysqlAndPostgres($query, $column, $point, $distance),
@@ -91,7 +91,7 @@ private function selectDistanceToMariaDb(Builder $query, string $column, Point $
9191
);
9292
}
9393

94-
private function withinDistanceToMysqlAndPostgres(Builder $query, string $column, Point $point, int $distance): Builder
94+
private function withinDistanceToMysqlAndPostgres(Builder $query, string $column, Point $point, float $distance): Builder
9595
{
9696
return $query
9797
->whereRaw("ST_AsText({$column}) != ?", [
@@ -111,7 +111,7 @@ private function withinDistanceToMysqlAndPostgres(Builder $query, string $column
111111
);
112112
}
113113

114-
private function withinDistanceToMariaDb(Builder $query, string $column, Point $point, int $distance): Builder
114+
private function withinDistanceToMariaDb(Builder $query, string $column, Point $point, float $distance): Builder
115115
{
116116
return $query
117117
->whereRaw("ST_AsText({$column}) != ?", [

0 commit comments

Comments
 (0)