names should now be consistent and collision-free.
- Improve handling of explicit key attr in ResultSet::find
- Add warnings for non-unique ResultSet::find queries
+ - Changed Storage::DBI::Replication to Storage::DBI::Replicated, fixed
+ some problems using this with versioned databases, added some docs
0.08010 2008-03-01 10:30
- Fix t/94versioning.t so it passes with latest SQL::Translator
Inflates the first result without creating a cursor if the resultset has
any records in it; if not returns nothing. Used by L</find> as an optimisation.
-Can optionally take an additional condition *only* - this is a fast-code-path
-method; if you need to add extra joins or similar call ->search and then
-->single without a condition on the $rs returned from that.
+Can optionally take an additional condition B<only> - this is a fast-code-path
+method; if you need to add extra joins or similar call L</search> and then
+L</single> without a condition on the L<DBIx::Class::ResultSet> returned from
+that.
+
+B<Note>: As of 0.08100, this method assumes that the query returns only one
+row. If more than one row is returned, you will receive a warning:
+
+ Query returned more than one row
+
+In this case, you should be using L</first> or L</find> instead.
=cut
my $self = shift;
my ($rv, $sth, @bind) = $self->_select(@_);
my @row = $sth->fetchrow_array;
- ## TODO, we need to decide if we should throw an error when select_single
- ## returns more than one row
- #carp "Query returned more than one row" if $sth->fetchrow_array;
+ if(@row && $sth->fetchrow_array) {
+ carp "Query returned more than one row. SQL that returns multiple rows is DEPRECATED for ->find and ->single";
+ }
# Need to call finish() to work round broken DBDs
$sth->finish();
return @row;
$artist_rs = $schema->resultset("Artist");
warning_is {
$artist_rs->find({}, { key => 'primary' })
-} "DBIx::Class::ResultSet::find(): Query returned more than one row", "Non-unique find generated a cursor inexhaustion warning";
+} "DBIx::Class::ResultSet::find(): Query returned more than one row. SQL that returns multiple rows is DEPRECATED for ->find and ->single"
+ => "Non-unique find generated a cursor inexhaustion warning";
$artist_rs = $schema->resultset("Artist")->search({}, { prefetch => 'cds' });
warning_is {
is $artist => undef
=> 'Nothing Found!';
-
- warn dump $artist->get_columns if $artist;
}