in reply to DBIx::Class Randomise datbase primary keys for testing.

By default DBIx::Class lets the database generate the primary key.

And I think that's a very sensible default; so you should investigate if your database has a way to customize primary key generation.

  • Comment on Re: DBIx::Class Randomise datbase primary keys for testing.

Replies are listed 'Best First'.
Re^2: DBIx::Class Randomise datbase primary keys for testing.
by afoken (Chancellor) on Nov 24, 2010 at 14:04 UTC

    If one creates a complete database scheme just for testing, as done in the original post, inserting a random number of dummy records into each of the tables could be sufficient. On a RDBMS with real sequences (like Oracle), creating the sequences in a way that they start at a random number should give a similar effect.

    A different approach, again needing sequences, would be to use a single sequence to generate all IDs, at least for the test database. That would reliably detect that special problem of using IDs from a wrong table.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)