Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix POD about using transactions with find_or_create #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/DBIx/Class/ResultSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3001,8 +3001,12 @@ subsequently result in spurious row creation.
B<Note>: Because find_or_create() reads from the database and then
possibly inserts based on the result, this method is subject to a race
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.
the find has completed and before the create has started.
Using find_or_create() inside a transaction I<does not> fix this problem -
if another process created the row after the transaction started, then when
the transaction with the newly-created row is committed, that insert
will either result in a duplicate row, or fail due to uniqueness
constraints.

B<Note>: Take care when using C<find_or_create> with a table having
columns with default values that you intend to be automatically
Expand Down