Can DataMapper use a true Enumerable column?

101 views Asked by At

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?

1

There are 1 answers

0
Reactormonk On

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 true Enum type, but it should be good enough if you know yours does support it.