Not working from laravel but generated query works on mysql console
dhcmega opened this issue · 1 comments
dhcmega commented
Hi
This is the situation:
I have this record:
INSERT INTO `geometries` (`id`, `account_id`, `type`, `name`, `geometry`, `created_at`, `updated_at`, `deleted_at`)
VALUES
(1, 1, 'coming_home', 'Prueba', 'POLYGON((-64.131126704102 -32.576934630156,-63.678819575195 -40.72449417635,-55.22764159668 -37.581725064771,-58.292827143555 -32.678770992146,-64.131126704102 -32.576934630156))', '2020-11-20 12:25:33', '2021-04-23 09:26:17', NULL);I want to know if this point is inside the polygon, the method I use is this:
$point = new \Grimzy\LaravelMysqlSpatial\Types\Point(-38.079191,-57.588594);
$result = \App\Models\Geometry::where('type', 'coming_home')->contains('geometry', $point)->first();Using the debugbar, I see that this is the query it generates:
SELECT * FROM `geometries` WHERE `type` = 'coming_home' AND st_contains(`geometry`, ST_GeomFromText('POINT(-57.5886223 -38.080722)')) AND `geometries`.`deleted_at` IS NULL AND `geometries`.`account_id` > 0 LIMIT 1It gives no results. As if the point is not inside the polygon.
But, if I run this query using SequelAce, it works!
Any ideas?
Thanks for reading!
dhcmega commented
I have deleted and recreated the table using the info from DESC before deleting it and it worked. I don't understand why or how.