X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FDBIx%2FClass.pm;h=4ca3f933a941fd461a44a246e42e218f31a52950;hb=b83736a7d3235d2f50fe5695550eb3637432d960;hp=c84f73ee9f2b7449b9a926b3771e548c9187d491;hpb=e089c417ce04bb60a7d0644cb858f83049e64684;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index c84f73e..4ca3f93 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -15,7 +15,9 @@ $DEBUG = 0 unless defined $DEBUG; use Exporter; use SQL::Translator::Utils qw(debug normalize_name); use DBIx::Class::Carp qw/^SQL::Translator|^DBIx::Class|^Try::Tiny/; +use DBIx::Class::_Util 'dbic_internal_try'; use DBIx::Class::Exception; +use Class::C3::Componentised; use Scalar::Util 'blessed'; use Try::Tiny; use namespace::clean; @@ -53,8 +55,11 @@ sub parse { DBIx::Class::Exception->throw('No DBIx::Class::Schema') unless ($dbicschema); if (!ref $dbicschema) { - eval "require $dbicschema" - or DBIx::Class::Exception->throw("Can't load $dbicschema: $@"); + dbic_internal_try { + Class::C3::Componentised->ensure_class_loaded($dbicschema) + } catch { + DBIx::Class::Exception->throw("Can't load $dbicschema: $_"); + } } if ( @@ -122,6 +127,10 @@ sub parse { name => $table_name, type => 'TABLE', ); + + my $ci = $source->columns_info; + + # same order as add_columns foreach my $col ($source->columns) { # assuming column_info in dbic is the same as DBI (?) @@ -132,7 +141,7 @@ sub parse { is_auto_increment => 0, is_foreign_key => 0, is_nullable => 0, - %{$source->column_info($col)} + %{$ci->{$col} || {}} ); if ($colinfo{is_nullable}) { $colinfo{default} = '' unless exists $colinfo{default}; @@ -171,9 +180,9 @@ sub parse { # Ignore any rel cond that isn't a straight hash next unless ref $rel_info->{cond} eq 'HASH'; - my $relsource = try { $source->related_source($rel) }; + my $relsource = dbic_internal_try { $source->related_source($rel) }; unless ($relsource) { - carp "Ignoring relationship '$rel' - related resultsource '$rel_info->{class}' is not registered with this schema\n"; + carp "Ignoring relationship '$rel' on '$moniker' - related resultsource '$rel_info->{class}' is not registered with this schema\n"; next; }; @@ -192,7 +201,7 @@ sub parse { for ( keys %{$rel_info->{cond}} ) { unless (exists $other_columns_idx{$_}) { - carp "Ignoring relationship '$rel' - related resultsource does not contain one of the specified columns: '$_'\n"; + carp "Ignoring relationship '$rel' on '$moniker' - related resultsource '@{[ $relsource->source_name ]}' does not contain one of the specified columns: '$_'\n"; next REL; } } @@ -528,12 +537,13 @@ Limit the amount of parsed sources by supplying an explicit list of source names L, L -=head1 AUTHORS - -See L. +=head1 FURTHER QUESTIONS? -=head1 LICENSE +Check the list of L. -You may distribute this code under the same terms as Perl itself. +=head1 COPYRIGHT AND LICENSE -=cut +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L.