Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac69ee9

Browse filesBrowse files
committed
Fix issue where the WKB of empty GeometryCollections was not getting parsed
1 parent e5e4c89 commit ac69ee9
Copy full SHA for ac69ee9

File tree

Expand file treeCollapse file tree

3 files changed

+5
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+5
-2
lines changed

‎src/Eloquent/SpatialTrait.php

Copy file name to clipboardExpand all lines: src/Eloquent/SpatialTrait.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function setRawAttributes(array $attributes, $sync = false)
104104
$spatial_fields = $this->getSpatialFields();
105105

106106
foreach ($attributes as $attribute => &$value) {
107-
if (in_array($attribute, $spatial_fields) && is_string($value) && strlen($value) >= 15) {
107+
if (in_array($attribute, $spatial_fields) && is_string($value) && strlen($value) >= 13) {
108108
$value = Geometry::fromWKB($value);
109109
}
110110
}

‎tests/Integration/Models/GeometryModel.php

Copy file name to clipboardExpand all lines: tests/Integration/Models/GeometryModel.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ class GeometryModel extends Model
99

1010
protected $table = 'geometry';
1111

12-
protected $spatialFields = ['location', 'line'];
12+
protected $spatialFields = ['location', 'line', 'multi_geometries'];
1313
}

‎tests/Integration/SpatialTest.php

Copy file name to clipboardExpand all lines: tests/Integration/SpatialTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ public function testInsertEmptyGeometryCollection()
251251
$geo->multi_geometries = new GeometryCollection([]);
252252
$geo->save();
253253
$this->assertDatabaseHas('geometry', ['id' => $geo->id]);
254+
255+
$geo2 = GeometryModel::find($geo->id);
256+
$this->assertInstanceOf(GeometryCollection::class, $geo2->multi_geometries);
254257
}
255258

256259
public function testUpdate()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.