Skip Menu |

This queue is for tickets about the DBIx-Class-Fixtures CPAN distribution.

Report information
The Basics
Id: 108018
Status: new
Priority: 0/
Queue: DBIx-Class-Fixtures

People
Owner: Nobody in particular
Requestors: andy [...] andybev.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Inserting data in original order
Date: Wed, 28 Oct 2015 12:11:19 +0000
To: bug-DBIx-Class-Fixtures [...] rt.cpan.org
From: Andrew Beverley <andy [...] andybev.com>
Hi, Would it be possible to have Fixtures populate data in the original order please? Currently the fixtures are read from the relevant directory, but in an apparent random order. The following patch works as a proof of concept (it's not possible to use IO:All's all() method, as that returns the files sorted alphanumerically, not numerically): --- a/Fixtures-old.pm +++ b/Fixtures-new.pm @@ -1361,8 +1361,10 @@ sub populate { my $rs = $schema->resultset($source); my $source_dir = io->catdir($tmp_fixture_dir, $self->_name_for_source($rs->result_source)); next unless (-e "$source_dir"); + # Disable numeric warnings? + my @all = sort { int($a->filename) <=> int($b->filename) } $source_dir->all; my @rows; - while (my $file = $source_dir->next) { + foreach my $file (@all) + { next unless ($file =~ /\.fix$/); next if $file->is_dir; my $contents = $file->slurp; Thanks, Andy