From: Robert Buels Date: Tue, 15 Sep 2009 20:45:32 +0000 (+0000) Subject: doc patch, clarified warning about using find_or_create() and friends on tables with... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b3ff132c9a424c303aa69d69ba9c596c01103562;p=dbsrgits%2FDBIx-Class-Historic.git doc patch, clarified warning about using find_or_create() and friends on tables with auto-increment or similar columns --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 005b605..9625e8c 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2196,13 +2196,14 @@ You most likely want this method when looking for existing rows using a unique constraint that is not the primary key, or looking for related rows. -If you want objects to be saved immediately, use L instead. +If you want objects to be saved immediately, use L +instead. -B: C is probably not what you want when creating a -new row in a table that uses primary keys supplied by the -database. Passing in a primary key column with a value of I -will cause L to attempt to search for a row with a value of -I. +B: Take care when using C with a table having +columns with values that are automatically supplied by the database +(e.g. an auto_increment primary key column). In normal usage, the +value of such columns should NOT be specified in the call to +C. =cut @@ -2344,11 +2345,11 @@ condition. Another process could create a record in the table after the find has completed and before the create has started. To avoid this problem, use find_or_create() inside a transaction. -B: C is probably not what you want when creating -a new row in a table that uses primary keys supplied by the -database. Passing in a primary key column with a value of I -will cause L to attempt to search for a row with a value of -I. +B: Take care when using C with a table having +columns with values that are automatically supplied by the database +(e.g. an auto_increment primary key column). In normal usage, the +value of such columns should NOT be specified in the call to +C. See also L and L. For information on how to declare unique constraints, see L. @@ -2411,11 +2412,11 @@ If the C is specified as C, it searches only on the primary key. See also L and L. For information on how to declare unique constraints, see L. -B: C is probably not what you want when -looking for a row in a table that uses primary keys supplied by the -database, unless you actually have a key value. Passing in a primary -key column with a value of I will cause L to attempt to -search for a row with a value of I. +B: Take care when using C with a table having +columns with values that are automatically supplied by the database +(e.g. an auto_increment primary key column). In normal usage, the +value of such columns should NOT be specified (even as undef) in the +call to C. =cut @@ -2472,7 +2473,13 @@ For example: $cd->insert; } -See also L, L and L. +B: Take care when using C with a table having +columns with values that are automatically supplied by the database +(e.g. an auto_increment primary key column). In normal usage, the +value of such columns should NOT be specified in the call to +C. + +See also L, L and L. =cut