Bill Moseley wrote:
> This is suppose to be an ORM-neutral question.
>=20
> I often use lookup tables in the database, even for things like, say,
> cart_status:
>=20
> create table cart_status (
> id SERIAL PRIMARY KEY,
> name text NOT NULL,
> active boolean NOT NULL DEFAULT TRUE
> );
>=20
> -- trust the sequence, Luke
> insert into cart_status (name) values ('Pending');
> insert into cart_status (name) values ('Completed');
>=20
> Then things like this are nice:
>=20
> [% cart.cart_status.name %]
>=20
> And can do this:
>=20
> update cart_status set name =3D 'Finished' where name =3D 'Complete=
d';
>=20
> And add new lookup options:
>=20
> insert into cart_status (name) values ('Orphaned');
>=20
>=20
> but this is not so nice:
>=20
> $cart_class->search( cart_status =3D> 1 );
>=20
>=20
> So, what have you found that works nicely?
>=20
> use MyApp::Const qw/ cart_pending /; # potentially long list
> cart_status =3D> cart_pending # runtime checking
>=20
> use MyApp::Const qw/ :cart /; # Shorter list :)
>=20
>=20
> cart_status =3D> MyApp::CONST::pending, # global constants
>=20
>=20
> # Make it very clear where a constant should be used
> # by adding the constants as methods to the cart namespace
>=20
> cart_status =3D> $cart_class->pending_status
>=20
>=20
>=20
>=20
>=20Why not just inflate/deflate into your own Status object? Granted, that's not ORM neutral...
signature.asc
Description: OpenPGP digital signature
_______________________________________________ List: [email protected] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
