[Catalyst] Constants that refer to rows in a lookup table.
Bill Moseley
moseley at hank.org
Wed May 23 00:53:45 GMT 2007
On Tue, May 22, 2007 at 04:36:06PM -0700, mla wrote:
>
> The PKs seem arbitrary in this case. I don't know if they
> should be referenced at all. I'd tend to use a subselect...
>
> UPDATE carts SET cart_status_id = (
> SELECT id FROM cart_status WHERE name = 'Completed'
> );
>
> But in a more ORM way, maybe something like
>
> my $status = Cart::Status->fetch(name => 'Pending');
Ya, but "Pending" is the description of the status, not the actual
abstract status.
Your cart is: [% cart.cart_status.name | html %]
Manager makes decision:
update cart_status set name = 'Not Completed' where name = 'Pending';
This still works:
Your cart is: [% cart.cart_status.name | html %]
But everywhere you did this is now broken:
my $status = Cart::Status->fetch(name => 'Pending');
But if I did this everywhere instead:
my $status = Cart::Status->fetch(name => cart_pending_status );
I'd still be on the beach.
But the question was how do I represent constants best?
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list