-1

I've got a column called 'coordinates' of type 'point'.

This query:

update `my-db`.`community` 
set `coordinates`= POINT( 31.9931217, 35.2823115 ) 
where 'id' = 1;

Returns the following error:

cannot get geometry object from data you send to the GEOMETRY field

What is the proper formatting here?

GMB
  • 216,147
  • 25
  • 84
  • 135
Boris K
  • 3,442
  • 9
  • 48
  • 87

2 Answers2

1

To start with: 'id' is not a valid column name (that's a string litteral). As a general hint, you should avoid quoting the column names unless it is really necessary (ie when the name contains special characters or starts with a number, or clashes with a reserved word).

Apart from that, your syntax should work, as described in the documentation and tested in this DB Fiddle.

As an alernative, you can also try and use ST_GeomFromText(), as follows:

update `my-db`.`community` 
SET `coordinates`= ST_GeomFromText('POINT(31.9931217 35.2823115)')
where `id` = 1;
GMB
  • 216,147
  • 25
  • 84
  • 135
  • 1
    Point(x, y) should also return a point object. See https://dev.mysql.com/doc/refman/8.0/en/gis-mysql-specific-functions.html#function_point – Shadow Dec 05 '19 at 21:41
  • @Shadow: you are correct, I tested it... I modified my answer accordingly. Thanks for the information... and for the update on my answer! – GMB Dec 05 '19 at 22:04
0

Looks like the correct syntax is

UPDATE my-db.community SET coordinates=GeomFromText('POINT(31.9931217 35.2823115)') WHERE 'id' = 1;

Try and see

Arun Kamalanathan
  • 8,107
  • 4
  • 23
  • 39
  • Nope, point(x, y) should also return a point object. See https://dev.mysql.com/doc/refman/8.0/en/gis-mysql-specific-functions.html#function_point – Shadow Dec 05 '19 at 21:40