1 package DBIx::Class::Relationship::HasOne;
7 shift->_has_one('LEFT' => @_);
11 shift->_has_one(undef => @_);
15 my ($class, $join_type, $rel, $f_class, @columns) = @_;
17 if (ref $columns[0]) {
18 $cond = shift @columns;
20 my ($pri, $too_many) = keys %{ $class->_primaries };
21 $class->throw( "might_have/has_one can only infer join for a single primary key; ${class} has more" )
24 if ($f_class->_columns->{$rel}) {
27 ($f_key, $too_many) = keys %{ $f_class->_primaries };
28 $class->throw( "might_have/has_one can only infer join for a single primary key; ${f_class} has more" )
31 $cond = { "foreign.${f_key}" => "self.${pri}" },
33 shift(@columns) unless defined $columns[0]; # Explicit empty condition
35 if (ref $columns[0] eq 'HASH') {
36 %attrs = %{shift @columns};
38 shift(@columns) unless defined $columns[0]; # Explicit empty attrs
39 $class->add_relationship($rel, $f_class,
41 { accessor => 'single', (@columns ? (proxy => \@columns) : ()),
42 cascade_update => 1, cascade_delete => 1,
43 ($join_type ? ('join_type' => $join_type) : ()),