X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FBase.pm;h=66847c3ed2b53012106d86e1511f157fe1ce0ed5;hb=57a9fc92e7f892fa0bf37a537ec835000d087c85;hp=6754b0e91b2d945c83c9b5420bc7d64b08292497;hpb=cfc5dce3341302d6487dd2c18b3e2e4c11065bdf;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 6754b0e..66847c3 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -86,6 +86,7 @@ __PACKAGE__->mk_group_accessors('simple', qw/ preserve_case col_collision_map real_dump_directory + datetime_undef_if_invalid /); =head1 NAME @@ -459,6 +460,15 @@ columns with the DATE/DATETIME/TIMESTAMP data_types. Sets the locale attribute for L for all columns with the DATE/DATETIME/TIMESTAMP data_types. +=head2 datetime_undef_if_invalid + +Pass a C<0> for this option when using MySQL if you B want C<< +datetime_undef_if_invalid => 1 >> in your column info for DATE, DATETIME and +TIMESTAMP columns. + +The default is recommended to deal with data such as C<00/00/00> which +sometimes ends up in such columns in MySQL. + =head2 config_file File in Perl format, which should return a HASH reference, from which to read @@ -1148,7 +1158,8 @@ sub _reload_class { eval_without_redefine_warnings ("require $class"); } catch { - die "Failed to reload class $class: $_"; + my $source = slurp $self->_get_dump_filename($class); + die "Failed to reload class $class: $_.\n\nCLASS SOURCE:\n\n$source"; }; } @@ -1564,9 +1575,10 @@ sub _resolve_col_accessor_collisions { die $@ if $@; push @methods, @{ Class::Inspector->methods($class) || [] }; - push @methods, @{ Class::Inspector->methods('UNIVERSAL') || [] }; } + push @methods, @{ Class::Inspector->methods('UNIVERSAL') }; + my %methods; @methods{@methods} = (); @@ -1599,10 +1611,6 @@ EOF } } } - - # FIXME: it appears that this method should also check that the - # default accessor (i.e. the column name itself) is not colliding - # with any of these methods } # use the same logic to run moniker_map, column_accessor_map, and @@ -1630,8 +1638,7 @@ sub _default_column_accessor_name { my $accessor_name = $column_name; $accessor_name =~ s/\W+/_/g; - # for backcompat - if( ($self->naming->{column_accessors}||'') =~ /(\d+)/ && $1 < 7 ) { + if ((($self->naming->{column_accessors}||'') =~ /(\d+)/ && $1 < 7) || (not $self->preserve_case)) { # older naming just lc'd the col accessor and that's all. return lc $accessor_name; } @@ -1639,6 +1646,7 @@ sub _default_column_accessor_name { return join '_', map lc, split_name $column_name; } + sub _make_column_accessor_name { my ($self, $column_name, $column_context_info ) = @_;