Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Enum in model update/save is required even though it's already filled

Hi, I'm having strange issue on Phalcon 2.0.X and don't really know how should I even debug it. I've created a simple mysql table made of a few columns. One of them is item_condition column which basicly is an enum with a few options. And here is the problem:

I'm unable to update/save this model because it's constantly returning error message: item_condition is required even though it's already there and remains untouched. It works well after changing that field to varchar so I think that it's some issue with comparing strings of enums (What it says it's basicly that 'State1' from database != 'State1' in model fulfiled from database. What should I do?

edit: looks like this problem is fixed in phalcon 2.1.x



49.7k
Accepted
answer
edited Apr '16

I would suggest you to avoid using ENUM. Especially with ORM. The other way around would be to fill out your Model prior to update, with actual value from ENUM field from database. From my expirience with Phalcon's ORM, that kind of errors can be solved with:

https://docs.phalconphp.com/en/latest/reference/models.html#skipping-columns

skipAttributes ()

Sets a list of attributes that must be skipped from the generated INSERT/UPDATE statement

8 Reasons Why MySQL's ENUM Data Type Is Evil http://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/

When you should and should NOT use ENUM data type http://www.cubrid.org/blog/cubrid-life/when-you-should-and-should-not-use-enum-data-type/