We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

MySQL Spatial Point NULL Validation Bug?

Table with a POINT column cannot be updated.

CREATE TABLE `SomeModel` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`geo` point NOT NULL,
PRIMARY KEY (`id`),
SPATIAL KEY `geo` (`geo`),
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;
$m = SomeModel::findFirst(69);
$m->name = 'New Name';
$m->save();

Results in:

[0] => Phalcon\Mvc\Model\Message Object
    (
        [_type:protected] => PresenceOf
        [_message:protected] => geo is required
        [_field:protected] => geo
        [_model:protected] => 
        [_code:protected] => 0
    )

I can't use skipAttributesOnCreate because I need to update that POINT column at other times.

Setting useDynamicUpdate(true) does nothing.

NOTE: The POINT column has a value in the database, so it's not even null.

Thanks! Adam

IDK whenever ORM supports geometry types.

edited Aug '17

It would be great if there was a way to dynamically tell the ORM to NOT include the field on update or create. Sometimes I need to update the POINT column, which is easy (by using RawValue). But other times, I don't want to change that column. The ORM should allow me to perform an update on only a few columns. Or only changed columns (which the useDynamicUpdate method should do, but doesn't work in this case).

Love Phalcon, been using it in production on multiple projects for years. I have confidence that there is a solution or fix in the works. Until then, I am very very sad.