Well, what's the syntax for the SQL? Worst case, you can pass literal
SQL snippets to Manager/QueryBuilder to get the filter conditions you
want. See the middle of the "query" parameter documentation for
instructions:
http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/QueryBuilder.pm#query
-John
I don't recommend that. The only advantage of ENUM in MySQL is
reduced storage space. It won't prevent you from inserting garbage.
If you want to enforce a set of values, use a lookup table and a
foreign key constraint instead. That WILL prevent garbage from going
into the column.
> So everything's humming along and now I'm wishing I can do some
> comparison operations, like "is the status greater than signed" or
> "get the objects where other_field is something and status is less
> than paid".
If you used a lookup table, you could just have a second column for
the value of a status.
- Perrin
>
> On Wed, Nov 11, 2009 at 10:58 AM, Purdy
> <jpu...@finebooksmagazine.com> wrote:
>>
>> I'm working on a finite state machine webapp based on a 'status'
>> column. Based on some IRC conversations, it was recommended that I
>> use
>> an enum column.
>
> I don't recommend that. The only advantage of ENUM in MySQL is
> reduced storage space. It won't prevent you from inserting garbage.
Thats not true. If you run mysql with sql_mode='STRICT_ALL_TABLES',
which you
really should, then it will result in an error if you attempt to set
to a
string not in the enum list
Graham.
Good to know. Thanks.
- Perrin
You could use POSTGRESQL mode:
http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html#sqlmode_postgresql
You'd also want STRICT_ALL_TABLES.
- Perrin
Will those options turn off the "feature" where if a field is in the
SELECT but not the GROUP BY it will select a random representative
value rather than letting you know the query makes no sense?
(I was bitten by this one yesterday.)
Ben
ONLY_FULL_GROUP_BY
- Perrin