[Dbix-class] Auto-generate random primary keys

Christopher H. Laco claco at chrislaco.com
Tue Feb 28 17:59:45 CET 2006


Matt S Trout wrote:
> 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.
> 

And ironically enough, that's not much different than using a custom
UUIDMaker within the current branch...

-=Chris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060228/c1c972d8/attachment.pgp 


More information about the Dbix-class mailing list