X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FBase.pm;h=47d965456f4ced92e3689b5769d1400f7d4b4621;hb=abaf2c66f2293cf951b6cd44b95ff1924e344f5f;hp=d4a79187c99900e1a3b9659c7a1f1d548e864bae;hpb=cb54990b0b3e5b87aca62ff0a0f03ed274e4f6f7;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index d4a7918..47d9654 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -11,6 +11,8 @@ use Data::Dump qw/ dump /; use POSIX qw//; require DBIx::Class; +our $VERSION = '0.03999_01'; + __PACKAGE__->mk_ro_accessors(qw/ schema schema_class @@ -176,8 +178,8 @@ recommended way to access this functionality. =head2 dump_overwrite If set to a true value, the dumping code will overwrite existing files. -The default is false, which means the dumping code will die if it encounters -an existing file. +The default is false, which means the dumping code will skip the already +existing files. =head1 DEPRECATED CONSTRUCTOR OPTIONS @@ -364,23 +366,28 @@ sub _dump_to_dir { $self->_ensure_dump_subdirs($schema_class); my $schema_fn = $self->_get_dump_filename($schema_class); - croak "$schema_fn exists, will not overwrite" - if -f $schema_fn && !$self->dump_overwrite; - open(my $schema_fh, '>', $schema_fn) - or croak "Cannot open $schema_fn for writing: $!"; - print $schema_fh qq|package $schema_class;\n\n$tagline\n\n|; - print $schema_fh qq|use strict;\nuse warnings;\n\n|; - print $schema_fh qq|use base 'DBIx::Class::Schema';\n\n|; - print $schema_fh qq|__PACKAGE__->load_classes;\n|; - print $schema_fh qq|\n1;\n\n|; - close($schema_fh) - or croak "Cannot close $schema_fn: $!"; + if (-f $schema_fn && !$self->dump_overwrite) { + warn "$schema_fn exists, will not overwrite\n"; + } + else { + open(my $schema_fh, '>', $schema_fn) + or croak "Cannot open $schema_fn for writing: $!"; + print $schema_fh qq|package $schema_class;\n\n$tagline\n\n|; + print $schema_fh qq|use strict;\nuse warnings;\n\n|; + print $schema_fh qq|use base 'DBIx::Class::Schema';\n\n|; + print $schema_fh qq|__PACKAGE__->load_classes;\n|; + print $schema_fh qq|\n1;\n\n|; + close($schema_fh) + or croak "Cannot close $schema_fn: $!"; + } foreach my $src_class (sort keys %{$self->{_dump_storage}}) { $self->_ensure_dump_subdirs($src_class); my $src_fn = $self->_get_dump_filename($src_class); - croak "$src_fn exists, will not overwrite" - if -f $src_fn && !$self->dump_overwrite; + if (-f $src_fn && !$self->dump_overwrite) { + warn "$src_fn exists, will not overwrite\n"; + next; + } open(my $src_fh, '>', $src_fn) or croak "Cannot open $src_fn for writing: $!"; print $src_fh qq|package $src_class;\n\n$tagline\n\n|; @@ -488,11 +495,12 @@ sub _load_classes { $self->_dbic_stmt($table_class,'add_columns',@$cols); } else { - my %cols_hash; - foreach my $col (@$cols) { - $cols_hash{$col} = \%{($col_info->{$col})}; - } - $self->_dbic_stmt($table_class,'add_columns',%cols_hash); + my %col_info_lc = map { lc($_), $col_info->{$_} } keys %$col_info; + $self->_dbic_stmt( + $table_class, + 'add_columns', + map { $_, ($col_info_lc{$_}||{}) } @$cols + ); } my $pks = $self->_table_pk_info($table) || [];