- Add ResultSource Artist_UC_RS.
This will test cases where resultsource name is not the same as the
table name
- Fix t/12-populate-basic.t to use $source->from instead of $source->name
to find directory to load. dump uses ->from
use Path::Class;
use Data::Dumper;
-plan tests => 16;
+plan tests => 18;
# set up and populate schema
ok(my $schema = DBICTest->init_schema( ), 'got schema');
my $fixture_dir = dir('t/var/fixtures');
foreach my $class ($schema->sources) {
- my $source_dir = dir($fixture_dir, lc($class));
+ my $source_dir = dir($fixture_dir, lc $schema->source($class)->from);
is($schema->resultset($class)->count,
(-e $source_dir) ? scalar($source_dir->children) : 0,
"correct number of $set " . lc($class)
[ 17, 1, 2, "Apiary"],
[ 18, 1, 3, "Beehind You"],
]);
+
+ $schema->populate('Artist_UC_RS', [
+ [ qw/artistid name/ ],
+ [ 1, 'Caterwauler McCrae' ],
+ [ 2, 'Random Boy Band' ],
+ [ 3, 'We Are Goth' ],
+ [ 4, '' ], # Test overridden new will default name to "Test Name" using use_create => 1.
+ [ 32948, 'Big PK' ],
+ ]);
}
1;
use base qw/DBIx::Class::Schema/;
no warnings qw/qw/;
-
-__PACKAGE__->load_classes(qw/Artist CD Track Tag Producer CD_to_Producer/);
+
+__PACKAGE__->load_classes(qw/Artist CD Track Tag Producer CD_to_Producer Artist_UC_RS/);
1;
--- /dev/null
+package # hide from PAUSE
+ DBICTest::Schema::Artist_UC_RS;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('Artist_UC');
+__PACKAGE__->add_columns(
+ 'artistid' => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ 'name' => {
+ data_type => 'varchar',
+ size => 100,
+ is_nullable => 1,
+ },
+);
+__PACKAGE__->set_primary_key('artistid');
+
+sub new {
+ my ( $class, $args ) = @_;
+
+ $args->{name} = "Test Name" unless $args->{name};
+
+ return $class->next::method( $args );
+}
+
+1;
producerid INTEGER PRIMARY KEY NOT NULL,
name varchar(100) NOT NULL
);
+
+--
+-- Table:: Artist_UC
+--
+CREATE TABLE Artist_UC (
+ artistid INTEGER PRIMARY KEY NOT NULL,
+ name varchar(100)
+);
name varchar(100) NOT NULL
);
+--
+-- Table:: Artist_UC
+--
+CREATE TABLE Artist_UC (
+ artistid INTEGER PRIMARY KEY NOT NULL,
+ name varchar(100)
+);
+
+
COMMIT;
"sets": [{
"class": "Artist",
"quantity": 1
- }]
-}
\ No newline at end of file
+ },
+ {
+ "class": "Artist_UC_RS",
+ "quantity": 2
+ }]
+}