From: Dagfinn Ilmari Mannsåker Date: Wed, 31 Jan 2018 21:53:48 +0000 (+0000) Subject: Inline relevant parts of IntrospectableM2M X-Git-Tag: v0.07049~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-Schema-Loader.git;a=commitdiff_plain;h=c4ac99630d90770a4e467027420cb4445e721dd3 Inline relevant parts of IntrospectableM2M Quoth ribasushi: > The dependency is discouraged, and often outright dangerous from an > architectural standpoint. Having S::L explicitly depend on it, *just* > for a test is silly, as the test-side can be accomplished with an ad-hoc > override within the base test schema in the dist, which would result in > IM2M not being installed for vast majority of users. --- diff --git a/Changes b/Changes index 67db5bf..b327498 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader - Fix tests when the path to perl has spaces in it (GH#19) - Inline String::CamelCase::wordsplit() due to RT#123030 - Get enum values from DBD::Pg if it's new enough + - Remove dependency on DBIx::Class::IntrospectableM2M 0.07048_01 - 2018-02-23 - Convert from Module::Install to ExtUtils::MakeMaker + Distar (GH#17) diff --git a/Makefile.PL b/Makefile.PL index c699884..ed58c3d 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -22,8 +22,6 @@ my %eumm_args = ( 'Test::Warn' => '0.21', 'Test::Deep' => '0.107', 'Test::Differences' => '0.60', - # temporary, needs to be thrown out - 'DBIx::Class::IntrospectableM2M' => 0, # core, but specific versions not available on older perls 'File::Temp' => '0.16', 'File::Path' => '2.07', diff --git a/t/lib/IntrospectM2M.pm b/t/lib/IntrospectM2M.pm new file mode 100644 index 0000000..4852170 --- /dev/null +++ b/t/lib/IntrospectM2M.pm @@ -0,0 +1,28 @@ +package IntrospectM2M; + +use strict; +use warnings; +use base 'DBIx::Class'; + +__PACKAGE__->mk_classdata( _m2m_metadata => {} ); + +sub many_to_many { + my $class = shift; + my ($meth_name, $link, $far_side) = @_; + my $store = $class->_m2m_metadata; + die "You are overwritting another relationship's metadata" + if exists $store->{$meth_name}; + + my $attrs = { + accessor => $meth_name, + relation => $link, #"link" table or immediate relation + foreign_relation => $far_side, #'far' table or foreign relation + (@_ > 3 ? (attrs => $_[3]) : ()), #only store if exist + }; + + #inheritable data workaround + $class->_m2m_metadata({ $meth_name => $attrs, %$store}); + $class->next::method(@_); +} + +1; diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 1d425bb..b9948c0 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -243,7 +243,7 @@ sub setup_schema { additional_classes => 'TestAdditional', additional_base_classes => 'TestAdditionalBase', left_base_classes => [ qw/TestLeftBase/ ], - components => [ qw/TestComponent +TestComponentFQN IntrospectableM2M/ ], + components => [ qw/TestComponent +TestComponentFQN +IntrospectM2M/ ], inflect_plural => { loader_test4_fkid => 'loader_test4zes' }, inflect_singular => { fkid => 'fkid_singular' }, moniker_map => \&_monikerize,