Propel
Propel copied to clipboard
Sortable behavior not working with ENUM scope
When adding a sortable behavior scopped to a column that has a ENUM type, the rank is wrong on creation (and on all the futher rank manipulations done on the object).
A simple workaround is to override the getScopeValue
method in your object class.
In the base class, the method looks like this:
public function getScopeValue($returnNulls = true)
{
return $this->get{MyEnumColumn}();
}
So you have to override the method to make this method return the actual SQL value corresponding to your enum value like so:
public function getScopeValue($returnNulls = true)
{
return {MyObject}Peer::get{MyEnumColumn}SqlValue($this->get{MyEnumColumn}());
}
I know that this version of Propel is frozen so I won't make any PR regarding this issue. I don't know if this issue is fixed in Propel2, but I am still posting this simple trick here, it could help people still using this last stable version of Propel...
FYI, I reproduced the problem on Propel2. I will report it there as well...