Revision history for Perl extension DBIx::Class::Schema::Loader
- Fix many_to_many bridges with overlapping foreign keys
+ - Add option to allow extra columns in many_to_many link tables
- Document how to add perltidy markers via filter_generated_code
- Fix DB2 foreign-key introspection
- Remove dependency on List::MoreUtils and Sub::Name
moniker_to_table
uniq_to_primary
quiet
+ allow_extra_m2m_cols
/);
on tables to primary keys, assuming there is only one largest unique
constraint.
+=head2 allow_extra_m2m_cols
+
+Generate C<many_to_many> 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
relationship_attrs
rel_collision_map
rel_name_map
+ allow_extra_m2m_cols
_temp_classes
__tagger
/);
my $self = {
loader => $loader,
- schema => $loader->schema,
- inflect_plural => $loader->inflect_plural,
- inflect_singular => $loader->inflect_singular,
- relationship_attrs => $loader->relationship_attrs,
- rel_collision_map => $loader->rel_collision_map,
- rel_name_map => $loader->rel_name_map,
+ (map { $_ => $loader->$_ } qw(
+ schema inflect_plural inflect_singular
+ relationship_attrs rel_collision_map
+ rel_name_map allow_extra_m2m_cols
+ )),
_temp_classes => [],
};
my @link_table_primary_cols =
@{[ $self->schema->source($link_moniker)->primary_columns ]};
- next unless uniq(@{$class[0]{from_link_cols}}, @{$class[1]{from_link_cols}}) == @link_table_cols
- && @link_table_cols == @link_table_primary_cols;
+ next unless array_eq(
+ [ sort +uniq @{$class[0]{from_link_cols}}, @{$class[1]{from_link_cols}} ],
+ [ sort @link_table_primary_cols ],
+ ) && ($self->allow_extra_m2m_cols || @link_table_cols == @link_table_primary_cols);
foreach my $this (0, 1) {
my $that = $this ? 0 : 1;