From: Peter Rabbitson Date: Tue, 30 Sep 2008 12:48:35 +0000 (+0000) Subject: Better docs about single() X-Git-Tag: v0.08240~341 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=59776e0e42df0d10ca3b66d3d91207aa4c76e7e9;p=dbsrgits%2FDBIx-Class.git Better docs about single() --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 11f275c..72fa328 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -573,19 +573,29 @@ sub cursor { my $cd = $schema->resultset('CD')->single({ year => 2001 }); Inflates the first result without creating a cursor if the resultset has -any records in it; if not returns nothing. Used by L as an optimisation. +any records in it; if not returns nothing. Used by L as a lean version of +L. -Can optionally take an additional condition B - this is a fast-code-path -method; if you need to add extra joins or similar call L and then -L without a condition on the L returned from -that. +While this method can take an optional search condition (just like L) +being a fast-code-path it does not recognize search attributes. If you need to +add extra joins or similar, call L and then chain-call L on the +L returned. -B: 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: +=over + +=item B + +As of 0.08100, this method enforces the assumption that the preceeding +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 or L instead. +In this case, you should be using L or L instead, or if you really +know what you are doing, use the L attribute to explicitly limit the size +of the resultset. + +=back =cut