I prefer to write my own migrations and expressly define the column as ENUM.

Interesting, MySQL accepts both integer and string values for ENUMs (order 
important):

mysql> CREATE TABLE tbl (
    ->   options ENUM('foo', 'bar') NOT NULL DEFAULT 'foo'
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql> 
mysql> INSERT INTO tbl VALUES ('foo'), ('foo'), ('bar');
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM tbl WHERE options = 1;
+---------+
| options |
+---------+
| foo     |
| foo     |
+---------+
2 rows in set (0.00 sec)

mysql> SELECT * FROM tbl WHERE options = 2;
+---------+
| options |
+---------+
| bar     |
+---------+
1 row in set (0.00 sec)

mysql> 



On 26/06/2011, at 23:05, Pierre wrote:

> Hello all,
> 
> Datamapper is great, but I don't understand how enum and flags works
> with mysql adapter.
> 
> First, they both create a integer field in the table which is annoying
> because it sould be respectively an enum field and a set field.
> 
> Then I don't understant how to work with these integer values. For
> exemple I'm triying to do something like that :
> 
> some_model = SomeModel.get(1)
> Description.all(:conditions => ['color_list = NULL OR color_list = ?',
> some_model.color])
> 
> With color_list a Flag property and color an enum property from a
> model called some_model. It's not working.
> 
> Thanks,
> 
> Pierre
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "DataMapper" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/datamapper?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to