-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Numeric value out of range when inserting #80
Comments
This is probably a duplicate of #70, right? |
I managed to solve this by looking at the #71 PR. I added this code:
This shouldn't be necessary, but it solves the problem temporarily. |
@pelmered Thanks for the workaround! I’ve just stumbled upon the same issue while trying to assign a default value to a static::creating(function (self $model) {
if (is_null($model->location)) {
// Throws MySQL error: Numeric value out of range blah blah blah...
$model->location = Point($defaultLatitude, $defaultLongitude);
}
}); The code you isolated fixes the issue 👌 static::creating(function (self $model) {
if (is_null($model->location)) {
$point = Point($defaultLatitude, $defaultLongitude);
$model->geometries['location'] = $point;
$model->attributes['location'] = new SpatialExpression($point);
}
}); |
Thanks for looking at this! And sorry for responding so late. I'll try to look at #71 soon and put all of this in a tested PR. |
i'm having the same problem. is there any way instead of those two line above? as in the tutorial just new Point($lat, $lng) should be enough. use Grimzy\LaravelMysqlSpatial\Types\Point; and my controller: and when i add "use SpatialTrait" to my model, i get this error: |
@M-Barari In your $this->location = new Point($lat, $lng); by this $point = Point($lat, $lng);
$this->geometries['location'] = $point;
$this->attributes['location'] = new \Grimzy\LaravelMysqlSpatial\EloquentSpatialExpression($point); I can’t guarantee this will work (I cannot guess by just looking at your code) but if your issue is the same as the one described above, then it should help. As for your Welcome to GitHub, by the way. Here is a tip that you may find helpful : when writing code in comments, you can surround it by ` accents to display it with indentation and syntax highlighting. Like this:
You can replace the |
Facing the same issue when trying to save
I get SQL error
i have tried the proposed solution and my code is $lineString = new LineString($points);
$this->geometries['route_path'] = $lineString;
$this->attributes['route_path'] = new SpatialExpression($lineString); but still not fixed package version |
Please ignore my comment i believe the issue was because my migration was not correct Thanks |
I had this issue again now, but now it was because I didn't have I think this issue can be closed now. |
I get this error message when I do a simple insert to a Point field:
The only solutions I can find is to add
SpatialTrait
and$spatialFields
, but I already have them. This the relevant parts of the model:I have double and triple checked the code, but I can't find anything wrong.
Any ideas?
The text was updated successfully, but these errors were encountered: