X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FBase.pm;h=3cd33f1ff53185df27b33059ae0eb1b3ac6cde63;hb=f08818c44125aad840158cc95dff84d955a47411;hp=0b22a09fcf6787ccc8e72a0c483d3c778a6f1ee0;hpb=2c158baf9e6e6fd6502cf959d4a2a2a6a3e71261;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 0b22a09..3cd33f1 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -20,12 +20,12 @@ use File::Temp (); use Class::Unload; use Class::Inspector (); use Scalar::Util 'looks_like_number'; -use DBIx::Class::Schema::Loader::Utils qw/split_name dumper_squashed eval_package_without_redefine_warnings class_path slurp_file sigwarn_silencer/; +use DBIx::Class::Schema::Loader::Utils qw/split_name dumper_squashed eval_package_without_redefine_warnings class_path slurp_file sigwarn_silencer firstidx uniq/; use DBIx::Class::Schema::Loader::Optional::Dependencies (); use Try::Tiny; use DBIx::Class (); use Encode qw/encode decode/; -use List::MoreUtils qw/all any firstidx uniq/; +use List::Util qw/all any none/; use File::Temp 'tempfile'; use namespace::clean; @@ -84,6 +84,7 @@ __PACKAGE__->mk_group_ro_accessors('simple', qw/ moniker_to_table uniq_to_primary quiet + allow_extra_m2m_cols /); @@ -993,6 +994,13 @@ Automatically promotes the largest unique constraints with non-nullable columns on tables to primary keys, assuming there is only one largest unique constraint. +=head2 allow_extra_m2m_cols + +Generate C relationship bridges even if the link table has +extra columns other than the foreign keys. The primary key must still +equal the union of the foreign keys. + + =head2 filter_generated_code An optional hook that lets you filter the generated text for various classes @@ -1009,8 +1017,19 @@ be generated. filter_generated_code => sub { my ($type, $class, $text) = @_; - ... - return $new_code; + ... + return $new_code; + } + +You can also use this option to set L in your generated classes. This will leave +the generated code in the default format, but will allow you to tidy +your classes at any point in future, without worrying about changing the +portions of the file which are checksummed, since C will just +ignore all text between the markers. + + filter_generated_code => sub { + return "#<<<\n$_[2]\n#>>>"; } =head1 METHODS @@ -1272,7 +1291,7 @@ sub new { if (ref $self->moniker_parts ne 'ARRAY') { croak 'moniker_parts must be an arrayref'; } - if ((firstidx { $_ eq 'name' } @{ $self->moniker_parts }) == -1) { + if (none { $_ eq 'name' } @{ $self->moniker_parts }) { croak "moniker_parts option *must* contain 'name'"; } } @@ -2143,10 +2162,10 @@ sub _write_classfile { croak "filter '$filter' exited non-zero: $exit_code"; } } - if (not $text or not $text =~ /\bpackage\b/) { - warn("$class skipped due to filter") if $self->debug; - return; - } + if (not $text or not $text =~ /\bpackage\b/) { + warn("$class skipped due to filter") if $self->debug; + return; + } } # Check and see if the dump is in fact different