Vote #70988
完了Adding multiple times the same related issue relation is possible
0%
説明
See #4911, I added relation to #7445 twice in a row with Firefox (unstable) just pressing Enter key, maybe longer than normal.
journals
As explained in RoR documentation (both 2.3.x and 3.x, this excerpt is from "3.x'":http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of):
<pre>
Concurrency and integrity
Using this validation method in conjunction with ActiveRecord::Base#save does not guarantee the absence of duplicate record insertions, because uniqueness checks on the application level are inherently prone to race conditions.
(...)
This could even happen if you use transactions with the ‘serializable’ isolation level. The best way to work around this problem is to add a unique index to the database table using (...)#add_index.
(...)
The bundled ActiveRecord::ConnectionAdapters distinguish unique index constraint errors from other types of database errors by throwing an ActiveRecord::RecordNotUnique exception. For other adapters you will have to parse the (database-specific) exception message to detect such a case.
</pre>
A simple migration creating an unique index on @to@ and @from@ @issue_relation@ columns should do the job.
--------------------------------------------------------------------------------
Migration patch attached.
--------------------------------------------------------------------------------
Ok, since there is a migration, moving to major.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Migration committed with r8041.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------