X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSource.pm;h=3233e3ab4a1b45d8cd0883e6881e5e6666551e35;hb=wip%2Finsert_select_take2;hp=0a5e94bb2f87f9ba121053ea833b4b23d23f0226;hpb=4a0eed52f392b2e135385d0c06b06160200f3772;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 0a5e94b..3233e3a 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -627,7 +627,7 @@ sub primary_columns { # a helper method that will automatically die with a descriptive message if # no pk is defined on the source in question. For internal use to save # on if @pks... boilerplate -sub _pri_cols { +sub _pri_cols_or_die { my $self = shift; my @pcols = $self->primary_columns or $self->throw_exception (sprintf( @@ -638,6 +638,20 @@ sub _pri_cols { return @pcols; } +# same as above but mandating single-column PK (used by relationship condition +# inferrence) +sub _single_pri_col_or_die { + my $self = shift; + my ($pri, @too_many) = $self->_pri_cols_or_die; + + $self->throw_exception( sprintf( + "Operation requires a single-column primary key declared on '%s'", + $self->source_name || $self->result_class || $self->name || 'Unknown source...?', + )) if @too_many; + return $pri; +} + + =head2 sequence Manually define the correct sequence for your table, to avoid the overhead