From: Peter Rabbitson Date: Sat, 16 Oct 2010 21:33:47 +0000 (+0200) Subject: This is something we'd need in a case of general 'strict' mode X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3bf27de20ca00174d3cef5e4d45ced14c0e40500;p=dbsrgits%2FDBIx-Class.git This is something we'd need in a case of general 'strict' mode --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index f060d45..37b8bb6 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -637,6 +637,13 @@ sub find { sub _non_unique_find_fallback { my ($self, $cond, $attrs) = @_; + carp sprintf( + 'Search arguments do not satisfy any of the unique constraints of %s, ' + . 'falling back to a plain search on columns: %s', + $self->result_source->source_name, + join (', ', map { "'$_'" } sort keys %$cond ), + ); + return $self->_qualify_cond_columns( $cond, exists $attrs->{alias} diff --git a/t/relationship/update_or_create_multi.t b/t/relationship/update_or_create_multi.t index 6bb0e86..2cbf1a4 100644 --- a/t/relationship/update_or_create_multi.t +++ b/t/relationship/update_or_create_multi.t @@ -60,16 +60,18 @@ is_deeply ( 'CD year column updated correctly', ); -# expect a failing create: +# expect a failing create (with a warning): # the unique constraint is not complete, and there is nothing # in the database with such a year yet - insertion will fail due # to missing artist fk -throws_ok { - $genre->update_or_create_related ('cds', { - year => 2020, - title => 'the best thing since sliced bread', - }) -} qr/\Qcd.artist may not be NULL/, 'ambiguous find + create failed'; +warnings_exist { + throws_ok { + $genre->update_or_create_related ('cds', { + year => 2020, + title => 'the best thing since sliced bread', + }) + } qr/\Qcd.artist may not be NULL/, 'ambiguous find + create failed' +} qr/Search arguments do not satisfy any of the unique constraints/, 'warned on ambiguous condition'; # expect a create, after a failed search using *only* the # *current* relationship and the unique column constraints