From: Peter Rabbitson Date: Thu, 3 Dec 2009 12:24:04 +0000 (+0000) Subject: Source sanity check on subqueried update/delete X-Git-Tag: v0.08116~111 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e92e86369d8d655c5d62940e9cbd4ed93e4c7985;p=dbsrgits%2FDBIx-Class.git Source sanity check on subqueried update/delete --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 123ecd1..1288c47 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1581,6 +1581,14 @@ sub _subq_update_delete { # quick check if we got a sane rs on our hands my @pcols = $rsrc->primary_columns; + unless (@pcols) { + $self->throw_exception ( + sprintf ( + "You must declare primary key(s) on source '%s' (via set_primary_key) in order to update or delete complex resultsets", + $rsrc->source_name || $rsrc->from + ) + ); + } my $sel = $rs->_resolved_attrs->{select}; $sel = [ $sel ] unless ref $sel eq 'ARRAY';