From: skaufman Date: Mon, 11 Aug 2014 18:39:01 +0000 (+0100) Subject: added use_find_or_create X-Git-Tag: v1.001022_01~4^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=30421f98b4bf0806c5d6de42ae7abce9ec215076;p=dbsrgits%2FDBIx-Class-Fixtures.git added use_find_or_create --- diff --git a/lib/DBIx/Class/Fixtures.pm b/lib/DBIx/Class/Fixtures.pm index 61f3523..914b1b9 100644 --- a/lib/DBIx/Class/Fixtures.pm +++ b/lib/DBIx/Class/Fixtures.pm @@ -511,6 +511,7 @@ sub new { ignore_sql_errors => $params->{ignore_sql_errors}, dumped_objects => {}, use_create => $params->{use_create} || 0, + use_find_or_create => $params->{use_find_or_create} || 0, config_attrs => $params->{config_attrs} || {}, }; @@ -1190,10 +1191,14 @@ sub dump_all_config_sets { # optional, set to 1 to run ddl but not populate no_populate => 0, - # optional, set to 1 to run each fixture through ->create rather than have + # optional, set to 1 to run each fixture through ->create rather than have # each $rs populated using $rs->populate. Useful if you have overridden new() logic - # that effects the value of column(s). - use_create => 0, + # that effects the value of column(s). + use_create => 0, + + # optional, same as use_create except with find_or_create. + # Useful if you are populating a persistent data store. + use_find_or_create => 0, # Dont try to clean the database, just populate over whats there. Requires # schema option. Use this if you want to handle removing old data yourself @@ -1385,6 +1390,8 @@ sub populate { } if ( $params->{use_create} ) { $rs->create( $HASH1 ); + } elsif( $params->{use_find_or_create} ) { + $rs->find_or_create( $HASH1 ); } else { push(@rows, $HASH1); }