{{$NEXT}}
+1.001037 2017-09-20 20:42:03+00:00 UTC
+
+- ignore virtual columns in dump_object
+
1.001036 2016-03-21 14:59:55+00:00 UTC
- releasing as stable
1.001013
- fixed functionality in last release by more deeply cloning parameters, which
- prevents bad things when parameters get deleted in the wrong places. Also
+ prevents bad things when parameters get deleted in the wrong places. Also
be sure we clear state properly after a dump.
1.001012
to make it easier when you need to dump all the fixtures programatically.
- Added method 'dump_config_sets' to let you dump more than one set at a time
more easily
-- Added method 'dump_all_config_sets' which helps automate dumping all your
- current config sets to a directory.
+- Added method 'dump_all_config_sets' which helps automate dumping all your
+ current config sets to a directory.
1.001011
- Added an excludes resultsource option to the ->dump({all=>1,...}) feature
-# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.037.
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.008.
use strict;
use warnings;
"DBIx::Class::InflateColumn::FS" => "0.01007",
"Devel::Confess" => 0,
"ExtUtils::MakeMaker" => "6.59",
+ "Test::Fatal" => 0,
"Test::More" => "0.98"
},
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => "6.59"
},
"DISTNAME" => "DBIx-Class-Fixtures",
- "EXE_FILES" => [],
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.006001",
"NAME" => "DBIx::Class::Fixtures",
"JSON::Syck" => "1.27",
"MIME::Base64" => 0,
"Path::Class" => "0.32",
- "Scalar::Util" => "1.27",
- "Test::Compile::Internal" => 0,
- "Test::TempDir::Tiny" => 0
+ "Scalar::Util" => "1.27"
},
"TEST_REQUIRES" => {
+ "File::Path" => 0,
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
- "Test::More" => "0.98"
+ "Test::Compile::Internal" => 0,
+ "Test::More" => "0.98",
+ "Test::TempDir::Tiny" => 0
},
- "VERSION" => "1.001036",
+ "VERSION" => "1.001037",
"test" => {
"TESTS" => "t/*.t"
}
"Devel::Confess" => 0,
"ExtUtils::MakeMaker" => "6.59",
"File::Copy::Recursive" => "0.38",
+ "File::Path" => 0,
"File::Spec" => 0,
"File::Temp" => "0.2304",
"Hash::Merge" => "0.1",
"Path::Class" => "0.32",
"Scalar::Util" => "1.27",
"Test::Compile::Internal" => 0,
+ "Test::Fatal" => 0,
"Test::More" => "0.98",
"Test::TempDir::Tiny" => 0
);
ExtUtils::MakeMaker = 6.59
Test::More = 0.98
Devel::Confess = 0
+Test::Fatal = 0
[Prereqs]
Class::Accessor::Grouped = 0.1001
Path::Class = 0.32
Scalar::Util = 1.27
perl = 5.6.1
-Test::Compile::Internal = 0
IO::All = 0.85
-Test::TempDir::Tiny=0
+
+[Prereqs / TestRequires]
+Test::TempDir::Tiny = 0
+File::Path = 0
+Test::Compile::Internal = 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;
$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
/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.
# 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}}) {
--- /dev/null
+use strict;
+use warnings;
+
+use DBIx::Class::Fixtures;
+use Test::More;
+use Test::Fatal;
+use File::Path 'rmtree';
+
+use lib qw(t/lib/DBICTest);
+use Schema3;
+use Test::TempDir::Tiny;
+use IO::All;
+
+my $tempdir = tempdir;
+
+(my $schema = Schema3->connect(
+ 'DBI:SQLite::memory:','',''))->init_schema;
+
+ok my $row = $schema
+ ->resultset('Person')
+ ->first;
+
+ok $row->get_column('weight_to_height_ratio'),
+ 'has virtual column';
+
+my $fixtures = DBIx::Class::Fixtures
+ ->new({
+ config_dir => io->catfile(qw't var configs')->name,
+ debug => 0 });
+
+ok(
+ $fixtures->dump({
+ config => 'virtual-columns.json',
+ schema => $schema,
+ directory => io->catfile($tempdir, 'people')->name }),
+ 'fetch dump executed okay');
+
+ok $schema->resultset('Person')->delete;
+
+is exception {
+ $fixtures->populate({
+ no_deploy => 1,
+ schema => $schema,
+ directory => io->catfile($tempdir, 'people')->name
+ })
+}, undef, 'populated';
+
+$row = $schema->resultset('Person')->first;
+
+BAIL_OUT("can't continue without data") unless $row;
+
+ok $row->get_column('weight_to_height_ratio'),
+ 'still has virtual column';
+
+done_testing;
+
+END {
+ rmtree io->catfile(qw't var files')->name;
+ rmtree io->catfile($tempdir, 'people')->name;
+}
--- /dev/null
+package Schema3::Result::Person;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('person');
+
+__PACKAGE__->add_columns(
+ id => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ name => {
+ data_type => 'varchar',
+ size => 255,
+ },
+ weight => {
+ datatype => 'float',
+ },
+ height => {
+ datatype => 'float',
+ },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+# Add virtual column
+__PACKAGE__->resultset_attributes({
+ '+select' => [ \'weight/height' ],
+ '+as' => [ 'weight_to_height_ratio' ],
+});
+
+package Schema3;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->register_class(Person => 'Schema3::Result::Person');
+
+sub load_sql {
+ local $/ = undef;
+ my $sql = <DATA>;
+}
+
+sub init_schema {
+ my $sql = (my $schema = shift)
+ ->load_sql;
+
+ ($schema->storage->dbh->do($_) ||
+ die "Error on SQL: $_\n")
+ for split(/;\n/, $sql);
+}
+
+1;
+
+__DATA__
+CREATE TABLE person (
+ id INTEGER PRIMARY KEY NOT NULL,
+ name varchar(255) NOT NULL,
+ weight FLOAT NOT NULL,
+ height FLOAT NOT NULL
+);
+
+INSERT INTO person (name, weight, height)
+VALUES
+('Fred Flintstone', 220, 5.2),
+('Barney Rubble', 190, 4.8)
--- /dev/null
+{
+ "sets": [{
+ "class": "Person",
+ "quantity": "all",
+ }]
+}