https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292011-12-01T18:21:06ZRedmineRedmine - Defect #9685: Adding multiple times the same related issue relation is possiblehttps://www.redmine.org/issues/9685?journal_id=343592011-12-01T18:21:06ZEtienne Massip
<ul><li><strong>Subject</strong> changed from <i>Adding multiple times the same related issue is possible</i> to <i>Adding multiple times the same related issue relation is possible</i></li></ul><p>As explained in RoR documentation (both 2.3.x and 3.x, this excerpt is from <a href="http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of" class="external">3.x'</a>):<br /><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></p>
<p>A simple migration creating an unique index on <code>to</code> and <code>from</code> <code>issue_relation</code> columns should do the job.</p> Redmine - Defect #9685: Adding multiple times the same related issue relation is possiblehttps://www.redmine.org/issues/9685?journal_id=343612011-12-01T19:54:00ZEtienne Massip
<ul><li><strong>File</strong> <a href="/attachments/6844">add_unique_index_in_issue_relations.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/6844/add_unique_index_in_issue_relations.patch">add_unique_index_in_issue_relations.patch</a> added</li></ul><p>Migration patch attached.</p> Redmine - Defect #9685: Adding multiple times the same related issue relation is possiblehttps://www.redmine.org/issues/9685?journal_id=343622011-12-01T19:54:25ZEtienne Massip
<ul><li><strong>Target version</strong> changed from <i>Candidate for next minor release</i> to <i>Candidate for next major release</i></li></ul><p>Ok, since there is a migration, moving to major.</p> Redmine - Defect #9685: Adding multiple times the same related issue relation is possiblehttps://www.redmine.org/issues/9685?journal_id=343842011-12-02T22:29:18ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Target version</strong> changed from <i>Candidate for next major release</i> to <i>1.4.0</i></li></ul> Redmine - Defect #9685: Adding multiple times the same related issue relation is possiblehttps://www.redmine.org/issues/9685?journal_id=343882011-12-03T12:14:11ZEtienne Massip
<ul><li><strong>Status</strong> changed from <i>Confirmed</i> to <i>Resolved</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Migration committed with <a class="changeset" title="Enforced unicity of relations between 2 issues with a database index (#9685)." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/8041">r8041</a>.</p> Redmine - Defect #9685: Adding multiple times the same related issue relation is possiblehttps://www.redmine.org/issues/9685?journal_id=357492012-02-02T19:31:12ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li></ul>