From: Luke Saunders Date: Fri, 25 Apr 2008 16:31:56 +0000 (+0000) Subject: Optimised populate to take advantage of insert_bulk X-Git-Tag: v1.001002~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a962f1f85d6afd93c82fc85120c1ba862c393e42;p=dbsrgits%2FDBIx-Class-Fixtures.git Optimised populate to take advantage of insert_bulk --- diff --git a/Changes b/Changes index 521f118..0addf99 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,7 @@ Revision history for DBIx-Class-Fixtures - Added post_ddl and cascade attributes to populate (Drew Taylor) - Scalar refs in cond clauses handled in sets as well as fetches (Sebastian Willert) - Directory separators in primary keys do not cause a crash (Sebastian Willert) +- Optimised populate to take advantage of insert_bulk (Drew Taylor) 1.000001 - Added missing deps diff --git a/lib/DBIx/Class/Fixtures.pm b/lib/DBIx/Class/Fixtures.pm index 957b751..2c52ca6 100644 --- a/lib/DBIx/Class/Fixtures.pm +++ b/lib/DBIx/Class/Fixtures.pm @@ -840,6 +840,7 @@ sub populate { my $rs = $schema->resultset($source); my $source_dir = dir($tmp_fixture_dir, lc($rs->result_source->from)); next unless (-e $source_dir); + my @rows; while (my $file = $source_dir->next) { next unless ($file =~ /\.fix$/); next if $file->is_dir; @@ -847,8 +848,9 @@ sub populate { my $HASH1; eval($contents); $HASH1 = $fixup_visitor->visit($HASH1) if $fixup_visitor; - $rs->create($HASH1); + push(@rows, $HASH1); } + $rs->populate(\@rows); } if ($params->{post_ddl}) {