By default, DataMapper creates Integer columns in the database for Enum properties (docs). If you store the 2nd value in the Enum's array, it stores a 2.
Is there a way to get it to use a true Enum column?
By default, DataMapper creates Integer columns in the database for Enum properties (docs). If you store the 2nd value in the Enum's array, it stores a 2.
Is there a way to get it to use a true Enum column?
Take a look at the sources of
Enum
, copy/paste, and patch it accordingly. It should already overwrite all methods that are needed, so it shouldn't be too hard. Just remember that not all backends might support a trueEnum
type, but it should be good enough if you know yours does support it.