DBIx-Class-RandomColumns

 view release on metacpan or  search on metacpan

lib/DBIx/Class/RandomColumns.pm  view on Meta::CPAN

        my $set = $conf->{set};
        do { # check uniqueness if check => 1 for this column
            $id = '';
            # random id is as good as Perl's rand()
            $id .= $set->[int(rand(@$set))] for (1 .. $conf->{size});
        } while $check and
                $tries-- and
                $self->result_source->resultset->search({$column => $id})->count;
    }

    $self->throw_exception("escaped from busy loop in DBIx::Class::RandomColumns::get_random_column_id()")
        unless $tries;

    return $id;
}

1;

__END__

=head1 OPTIONS



( run in 0.261 second using v1.01-cache-2.11-cpan-87723dcf8b7 )