From: Jason M. Mills Date: Tue, 10 Feb 2009 05:30:07 +0000 (+0000) Subject: Merge 'trunk' into 'rt_bug_41083' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e99ba9d087c435bfc7ad74496d993daffe385c13;hp=f1417dab0ab14cdc77524368db71c7cdb89ade0d;p=dbsrgits%2FDBIx-Class-Historic.git Merge 'trunk' into 'rt_bug_41083' Merged trunk in to rt_bug_t41083 branch via svk merge. --- diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index 3024241..85eab8a 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -19,9 +19,6 @@ columns to be of the datetime, timestamp or date datatype. starts_when => { data_type => 'datetime' } ); -NOTE: You B load C B C. See -L for details. - Then you can treat the specified column as a L object. print "This event starts the month of ". diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index ba05001..518d6e8 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -771,17 +771,24 @@ sub set_inflated_columns { { my $rel = delete $upd->{$key}; $self->set_from_related($key => $rel); - $self->{_relationship_data}{$key} = $rel; + $self->{_relationship_data}{$key} = $rel; } elsif ($info && $info->{attrs}{accessor} - && $info->{attrs}{accessor} eq 'multi') { - $self->throw_exception( - "Recursive update is not supported over relationships of type multi ($key)" - ); + && $info->{attrs}{accessor} eq 'multi' + && ref $upd->{$key} eq 'ARRAY') { + my $others = delete $upd->{$key}; + foreach my $rel_obj (@$others) { + if(!Scalar::Util::blessed($rel_obj)) { + $rel_obj = $self->create_related($key, $rel_obj); + } + } + $self->{_relationship_data}{$key} = $others; +# $related->{$key} = $others; + next; } elsif ($self->has_column($key) && exists $self->column_info($key)->{_inflate_info}) { - $self->set_inflated_column($key, delete $upd->{$key}); + $self->set_inflated_column($key, delete $upd->{$key}); } } } diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 9222f80..1c75a50 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -208,12 +208,16 @@ sub load_namespaces { local *Class::C3::reinitialize = sub { }; use warnings 'redefine'; - foreach my $result (keys %results) { + # ensure classes are loaded and fetch properly sorted classes + $class->ensure_class_loaded($_) foreach(values %results); + my @subclass_last = sort { $results{$a}->isa($results{$b}) } keys(%results); + + foreach my $result (@subclass_last) { my $result_class = $results{$result}; - $class->ensure_class_loaded($result_class); my $rs_class = delete $resultsets{$result}; my $rs_set = $result_class->resultset_class; + if($rs_set && $rs_set ne 'DBIx::Class::ResultSet') { if($rs_class && $rs_class ne $rs_set) { warn "We found ResultSet class '$rs_class' for '$result', but it seems " diff --git a/t/39load_namespaces_rt41083.t b/t/39load_namespaces_rt41083.t new file mode 100644 index 0000000..ba99fe5 --- /dev/null +++ b/t/39load_namespaces_rt41083.t @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; + +use lib 't/lib'; + +plan tests => 4; + +sub _chk_warning { + defined $_[0]? + $_[0] !~ qr/We found ResultSet class '([^']+)' for '([^']+)', but it seems that you had already set '([^']+)' to use '([^']+)' instead/ : + 1 +} + +my $warnings; +eval { + local $SIG{__WARN__} = sub { $warnings .= shift }; + package DBICNSTest::RtBug41083; + use base 'DBIx::Class::Schema'; + __PACKAGE__->load_namespaces( + result_namespace => 'Schema_A', + resultset_namespace => 'ResultSet_A', + default_resultset_class => 'ResultSet' + ); +}; +ok(!$@) or diag $@; +ok(_chk_warning($warnings), 'expected no complaint'); + +eval { + local $SIG{__WARN__} = sub { $warnings .= shift }; + package DBICNSTest::RtBug41083; + use base 'DBIx::Class::Schema'; + __PACKAGE__->load_namespaces( + result_namespace => 'Schema', + resultset_namespace => 'ResultSet', + default_resultset_class => 'ResultSet' + ); +}; +ok(!$@) or diag $@; +ok(_chk_warning($warnings), 'expected no complaint') or diag $warnings; diff --git a/t/66relationship.t b/t/66relationship.t index fe0196c..94d7e87 100644 --- a/t/66relationship.t +++ b/t/66relationship.t @@ -275,8 +275,6 @@ is ($@, '', 'Staged insertion successful'); ok($new_artist->in_storage, 'artist inserted'); ok($new_related_cd->in_storage, 'new_related_cd inserted'); -TODO: { -local $TODO = "TODOify for multicreate branch"; my $new_cd = $schema->resultset("CD")->new_result({}); my $new_related_artist = $new_cd->new_related('artist', { 'name' => 'Marillion',}); lives_ok ( @@ -300,4 +298,3 @@ cmp_ok($relinfo->{attrs}{is_foreign_key_constraint}, '==', 1, "is_foreign_key_co my $rs_overridden = $schema->source('ForceForeign'); my $relinfo_with_attr = $rs_overridden->relationship_info ('cd_3'); cmp_ok($relinfo_with_attr->{attrs}{is_foreign_key_constraint}, '==', 0, "is_foreign_key_constraint defined for belongs_to relationships with attr."); -} diff --git a/t/96multi_create.t b/t/96multi_create.t index 4445f3f..e202c59 100644 --- a/t/96multi_create.t +++ b/t/96multi_create.t @@ -168,8 +168,6 @@ eval { }; diag $@ if $@; -TODO: { -local $TODO = "Todoify for multicreate branch"; # test might_have again but with a PK == FK in the middle (obviously not specified) eval { my $artist = $schema->resultset('Artist')->first; @@ -260,7 +258,6 @@ eval { ); }; diag $@ if $@; -} # nested find_or_create eval { diff --git a/t/lib/DBICNSTest/RtBug41083/ResultSet.pm b/t/lib/DBICNSTest/RtBug41083/ResultSet.pm new file mode 100644 index 0000000..2e30409 --- /dev/null +++ b/t/lib/DBICNSTest/RtBug41083/ResultSet.pm @@ -0,0 +1,5 @@ +package DBICNSTest::RtBug41083::ResultSet; +use strict; +use warnings; +use base 'DBIx::Class::ResultSet'; +1; diff --git a/t/lib/DBICNSTest/RtBug41083/ResultSet/Foo.pm b/t/lib/DBICNSTest/RtBug41083/ResultSet/Foo.pm new file mode 100644 index 0000000..9bf912a --- /dev/null +++ b/t/lib/DBICNSTest/RtBug41083/ResultSet/Foo.pm @@ -0,0 +1,8 @@ +package DBICNSTest::RtBug41083::ResultSet::Foo; +use strict; +use warnings; +use base 'DBICNSTest::RtBug41083::ResultSet'; + +sub fooBar { 1; } + +1; diff --git a/t/lib/DBICNSTest/RtBug41083/ResultSet_A/A.pm b/t/lib/DBICNSTest/RtBug41083/ResultSet_A/A.pm new file mode 100644 index 0000000..cb93955 --- /dev/null +++ b/t/lib/DBICNSTest/RtBug41083/ResultSet_A/A.pm @@ -0,0 +1,7 @@ +package DBICNSTest::RtBug41083::ResultSet_A::A; +use strict; +use warnings; +use base 'DBICNSTest::RtBug41083::ResultSet'; + +sub fooBar { 1; } +1; diff --git a/t/lib/DBICNSTest/RtBug41083/Schema/Foo.pm b/t/lib/DBICNSTest/RtBug41083/Schema/Foo.pm new file mode 100644 index 0000000..11f10e9 --- /dev/null +++ b/t/lib/DBICNSTest/RtBug41083/Schema/Foo.pm @@ -0,0 +1,8 @@ +package DBICNSTest::RtBug41083::Schema::Foo; +use strict; +use warnings; +use base 'DBIx::Class'; +__PACKAGE__->load_components('Core'); +__PACKAGE__->table('foo'); +__PACKAGE__->add_columns('foo'); +1; diff --git a/t/lib/DBICNSTest/RtBug41083/Schema/Foo/Sub.pm b/t/lib/DBICNSTest/RtBug41083/Schema/Foo/Sub.pm new file mode 100644 index 0000000..73ec679 --- /dev/null +++ b/t/lib/DBICNSTest/RtBug41083/Schema/Foo/Sub.pm @@ -0,0 +1,5 @@ +package DBICNSTest::RtBug41083::Schema::Foo::Sub; +use strict; +use warnings; +use base 'DBICNSTest::RtBug41083::Schema::Foo'; +1; diff --git a/t/lib/DBICNSTest/RtBug41083/Schema_A/A.pm b/t/lib/DBICNSTest/RtBug41083/Schema_A/A.pm new file mode 100644 index 0000000..ca626d7 --- /dev/null +++ b/t/lib/DBICNSTest/RtBug41083/Schema_A/A.pm @@ -0,0 +1,8 @@ +package DBICNSTest::RtBug41083::Schema_A::A; +use strict; +use warnings; +use base 'DBIx::Class'; +__PACKAGE__->load_components('Core'); +__PACKAGE__->table('a'); +__PACKAGE__->add_columns('a'); +1; diff --git a/t/lib/DBICNSTest/RtBug41083/Schema_A/A/Sub.pm b/t/lib/DBICNSTest/RtBug41083/Schema_A/A/Sub.pm new file mode 100644 index 0000000..1128e1e --- /dev/null +++ b/t/lib/DBICNSTest/RtBug41083/Schema_A/A/Sub.pm @@ -0,0 +1,5 @@ +package DBICNSTest::RtBug41083::Schema_A::A::Sub; +use strict; +use warnings; +use base 'DBICNSTest::RtBug41083::Schema_A::A'; +1;