[Dbix-class] Auto-generate random primary keys
Matt S Trout
dbix-class at trout.me.uk
Tue Feb 28 16:31:18 CET 2006
On Tue, Feb 28, 2006 at 03:55:08PM +0100, Bernhard Graf wrote:
> Hi,
>
> I just started playing around with DBIC.
>
> Some tables in my db have random primary keys created by eg.
> Digest::MD5::md5_hex($$, rand, time).
>
> Is there a recommended way to do this?
>
> I thought of a DBIC::PK::Auto::MD5 class, with an insert() that does
> basically:
>
> my $self = shift;
> $self->store_column(md5_hex($$, rand, time));
> $self->next::method(@_);
>
> Is that an appropriate approach?
http://search.cpan.org/~mikihoshi/DBIx-Class-RandomStringColumns-0.02/lib/DBIx/Class/RandomStringColumns.pm
seems to already have a similar implementation' might make a good basis for
what you're trying to do.
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Dbix-class
mailing list