From: Will Hawes Date: Wed, 28 Sep 2011 12:55:11 +0000 (+0100) Subject: make dump/populate work with mixed-case table names X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fpeople%2Fwdh%2Flc_table_name;p=dbsrgits%2FDBIx-Class-Fixtures.git make dump/populate work with mixed-case table names --- diff --git a/lib/DBIx/Class/Fixtures.pm b/lib/DBIx/Class/Fixtures.pm index 50b9fdf..e44827e 100644 --- a/lib/DBIx/Class/Fixtures.pm +++ b/lib/DBIx/Class/Fixtures.pm @@ -712,7 +712,7 @@ sub dump_object { # write dir and gen filename - my $source_dir = $params->{set_dir}->subdir(lc $src->from); + my $source_dir = $params->{set_dir}->subdir($src->from); $source_dir->mkpath(0, 0777); # strip dir separators from file name @@ -1163,7 +1163,7 @@ sub populate { foreach my $source (sort $schema->sources) { $self->msg("- adding " . $source); my $rs = $schema->resultset($source); - my $source_dir = $tmp_fixture_dir->subdir( lc $rs->result_source->from ); + my $source_dir = $tmp_fixture_dir->subdir( $rs->result_source->from ); next unless (-e $source_dir); my @rows; while (my $file = $source_dir->next) { diff --git a/t/07-dump-all.t b/t/07-dump-all.t index 57b73d7..7617733 100644 --- a/t/07-dump-all.t +++ b/t/07-dump-all.t @@ -7,7 +7,7 @@ use DBICTest; 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'); diff --git a/t/18-dump-mixed-case.t b/t/18-dump-mixed-case.t index 5deacbb..e23aacd 100644 --- a/t/18-dump-mixed-case.t +++ b/t/18-dump-mixed-case.t @@ -1,7 +1,7 @@ #!perl use DBIx::Class::Fixtures; -use Test::More tests => 3; +use Test::More tests => 4; use lib qw(t/lib); use DBICTest; use Path::Class; @@ -15,7 +15,7 @@ my $config_dir = 't/var/configs'; { # do dump ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir, debug => 0 }), 'object created with correct config dir'); - ok($fixtures->dump({ config => 'simple.json', schema => $schema, directory => 't/var/fixtures' }), 'simple dump executed okay'); + ok($fixtures->dump({ config => 'mixed-case.json', schema => $schema, directory => 't/var/fixtures' }), 'simple dump executed okay'); # check dump is okay my $dir = dir('t/var/fixtures/MixedCase'); diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index bf36d1b..b2f9322 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -200,6 +200,11 @@ sub populate_schema { [ 17, 1, 2, "Apiary"], [ 18, 1, 3, "Beehind You"], ]); + + $schema->populate('MixedCase', [ + [qw/ id name /], + [ 1, 'some name' ] + ]); } 1; diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm index 350eecc..52d756d 100644 --- a/t/lib/DBICTest/Schema.pm +++ b/t/lib/DBICTest/Schema.pm @@ -5,6 +5,6 @@ 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 MixedCase/); 1; diff --git a/t/lib/mysql.sql b/t/lib/mysql.sql index ca1b034..f6e614a 100644 --- a/t/lib/mysql.sql +++ b/t/lib/mysql.sql @@ -59,3 +59,12 @@ CREATE TABLE producer ( producerid INTEGER PRIMARY KEY NOT NULL, name varchar(100) NOT NULL ); + +-- +-- Table: MixedCase +-- +DROP TABLE IF EXISTS MixedCase; +CREATE TABLE MixedCase ( + id INTEGER PRIMARY KEY NOT NULL, + name varchar(100) NOT NULL +); diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index 1e21627..a4452a0 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -60,4 +60,12 @@ CREATE TABLE producer ( name varchar(100) NOT NULL ); +-- +-- Table: MixedCase +-- +CREATE TABLE MixedCase ( + id INTEGER PRIMARY KEY NOT NULL, + name varchar(100) NOT NULL +); + COMMIT;