-
Notifications
You must be signed in to change notification settings - Fork 52
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: 1416 Cannot get geometry object from data you send to the GEOMETRY field #69
Comments
Hi @Synchro, as I understand it, casts don't work when you use mass updates. You have to fetch the model before updating it. |
Ah, ok, that explains it. I will have to take the long way around! |
One thought – while casts might not be applied automatically, what should I do to make use of the casting manually? For example: $count = Checkout::query()
->where('user_id', $user->id)
->limit(1)
->update(
[
'return_location' => DB::raw((string)$return_location),
]
); My only concern here is that the default string representation might not be one that's compatible with what the DB is expecting. Is this the right way to do it, or do I need to call some |
There is no clean way to do that today. The logic happens here:
This code should work, although I didn't test it: $geometryCast = new GeometryCast(Point::class);
$model = new Checkout(); // just to get the DB connection out of it
$wkt = $geometryCast($model, '', $return_location, []); If you want, you can submit a PR that makes it less dirty. It should be a function that receives a DB connection and a |
* Add a manual casting function, fixes #69 * Requested changes for #70 * Update .run/Test.run.xml Co-authored-by: Matan Yadaev <[email protected]> * Update API.md Co-authored-by: Matan Yadaev <[email protected]> * Update tests/Objects/GeometryTest.php Co-authored-by: Matan Yadaev <[email protected]> * Update tests/Objects/GeometryTest.php Co-authored-by: Matan Yadaev <[email protected]> * Use expression generator in cast and builder, see #70 Co-authored-by: Matan Yadaev <[email protected]>
I'm getting a casting problem when running this update:
I have a
Point
value set from request properties like this:This is then used to update DB records:
but even though the Point object is valid, and has a cast set correctly in its model, it fails like this:
In other contexts this field works fine.
Is there some limitation I'm running into here, or a bug?
The text was updated successfully, but these errors were encountered: