Bill Moseley wrote:
> This is suppose to be an ORM-neutral question.
> 
> I often use lookup tables in the database, even for things like, say,
> cart_status:
> 
>     create table cart_status (
>         id      SERIAL PRIMARY KEY,
>         name    text NOT NULL,
>         active  boolean NOT NULL DEFAULT TRUE
>     );
> 
>     -- trust the sequence, Luke
>     insert into cart_status (name) values ('Pending');
>     insert into cart_status (name) values ('Completed');
> 
> Then things like this are nice:
> 
>     [% cart.cart_status.name %]
> 
> And can do this:
> 
>     update cart_status set name = 'Finished' where name = 'Completed';
> 
> And add new lookup options:
> 
>     insert into cart_status (name) values ('Orphaned');
> 
> 
> but this is not so nice:
> 
>     $cart_class->search( cart_status => 1 );

And just because you've mentioned cart... :-)
What's so wrong with cart_status => 1 ?

..where cart_status in (1, 2)

Constants aren't the devil. MyApp::Constants isn't abnormal.

Personally, I never store 'flags' as strings. You say 'pending', I say
'Pending'....and if the db is or isn't case sensitive?...

IF you do store it as strings, I'd say still use constants in your code
anyways...

-=Chris

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to