X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FHasOne.pm;fp=lib%2FDBIx%2FClass%2FRelationship%2FHasOne.pm;h=46e18e34b9f153804c2a02ec986f6cbad0e7a516;hb=b83736a7d3235d2f50fe5695550eb3637432d960;hp=665d13190b02c91a47e4d2b8d470301865e3891a;hpb=f064a2abb15858bb39a141ad50391d4191988d2c;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship/HasOne.pm b/lib/DBIx/Class/Relationship/HasOne.pm index 665d131..46e18e3 100644 --- a/lib/DBIx/Class/Relationship/HasOne.pm +++ b/lib/DBIx/Class/Relationship/HasOne.pm @@ -97,12 +97,18 @@ sub _validate_has_one_condition { return unless $self_id =~ /^self\.(.*)$/; my $key = $1; - $class->throw_exception("Defining rel on ${class} that includes '$key' but no such column defined here yet") - unless $class->result_source_instance->has_column($key); - my $column_info = $class->result_source_instance->column_info($key); - if ( $column_info->{is_nullable} ) { - carp(qq'"might_have/has_one" must not be on columns with is_nullable set to true ($class/$key). This might indicate an incorrect use of those relationship helpers instead of belongs_to.'); - } + + my $column_info = $class->result_source->columns_info->{$key} + or $class->throw_exception( + "Defining rel on ${class} that includes '$key' " + . 'but no such column defined there yet' + ); + + carp( + "'might_have'/'has_one' must not be used on columns with is_nullable " + . "set to true ($class/$key). This almost certainly indicates an " + . "incorrect use of these relationship helpers instead of 'belongs_to'" + ) if $column_info->{is_nullable}; } }