Merge branch 'cngarrison-test-fix'
[dbsrgits/DBIx-Class-Fixtures.git] / lib / DBIx / Class / Fixtures.pm
index 65806ed..376ce4a 100644 (file)
@@ -23,7 +23,7 @@ our $namespace_counter = 0;
 __PACKAGE__->mk_group_accessors( 'simple' => qw/config_dir
     _inherited_attributes debug schema_class dumped_objects config_attrs/);
 
-our $VERSION = '1.001036';
+our $VERSION = '1.001037';
 
 $VERSION = eval $VERSION;
 
@@ -557,7 +557,8 @@ or
  $fixtures->dump({
    all => 1, # just dump everything that's in the schema
    schema => $source_dbic_schema,
-   directory => '/home/me/app/fixtures' # output directory
+   directory => '/home/me/app/fixtures', # output directory
+   #excludes => [ qw/Foo MyView/ ], # optionally exclude certain sources
  });
 
 In this case objects will be dumped to subdirectories in the specified
@@ -567,9 +568,14 @@ directory. For example:
  /home/me/app/fixtures/artist/3.fix
  /home/me/app/fixtures/producer/5.fix
 
-schema and directory are required attributes. also, one of config or all must
+C<schema> and C<directory> are required attributes. also, one of C<config> or C<all> must
 be specified.
 
+The optional parameter C<excludes> takes an array ref of source names and can be
+used to exclude those sources when dumping the whole schema. This is useful if
+you have views in there, since those do not need fixtures and will currently result
+in an error when they are created and then used with C<populate>.
+
 Lastly, the C<config> parameter can be a Perl HashRef instead of a file name.
 If this form is used your HashRef should conform to the structure rules defined
 for the JSON representations.
@@ -848,7 +854,14 @@ sub dump_object {
   # write file
   unless ($exists) {
     $self->msg('-- dumping ' . "$file", 2);
-    my %ds = $object->get_columns;
+
+    # get_columns will return virtual columns; we just want stored columns.
+    # columns_info keys seems to be the actual storage column names, so we'll
+    # use that.
+    my $col_info = $src->columns_info;
+    my @column_names = keys %$col_info;
+    my %columns = $object->get_columns;
+    my %ds; @ds{@column_names} = @columns{@column_names};
 
     if($set->{external}) {
       foreach my $field (keys %{$set->{external}}) {