Branch: refs/heads/master
Home: https://github.com/openSUSE/open-build-service
Commit: 629577c2e58f551dae69ef398450acbb9a8e0d79
https://github.com/openSUSE/open-build-service/commit/629577c2e58f551dae69ef...
Author: Björn Geuken
Date: 2017-11-02 (Thu, 02 Nov 2017)
Changed paths:
M src/api/app/models/group.rb
M src/api/app/models/groups_user.rb
A src/api/db/migrate/20171102110929_disallow_null_for_group_id_in_groups_users.rb
M src/api/db/structure.sql
M src/api/spec/controllers/group_controller_spec.rb
Log Message:
-----------
[frontend] Fix deletion of groups_users
When deleting a group, we also want the related groups_user to be destroyed.
That's reflected with a 'dependent: :destroy'.
In PR #3393 it was already reported that this was not working and destroying a
group that has associated users (and groups_users), would cause a 500.
With 18680d611347d312142 the 500 error was solved, but the underlying
problem (not properly deleting groups users) persisted.
The cause of this issue was that the group model defined the n-to-m
relation to groups_users twice. Once via a has_many relation and once
via a has_and_belongs_to_many.
This doesn't seem to be valid, nor does it make any sense, and it caused
rails to create following SQL calls when a_group.destroy was called:
SQL (0.6ms) UPDATE `groups_users` SET `groups_users`.`group_id` = NULL WHERE `groups_users`.`group_id` = 1
SQL (0.4ms) DELETE FROM `groups_users` WHERE `groups_users`.`group_id` = 1
As you can see the second SQL query, that would delete the groups user, is
ineffective due to the first one.
By dropping one of the two n-to-m relations, we prevent Rails from
creating bogus SQL queries and thus fix the issue.
Commit: 59a3142c6fbd2766ea378238aee3d76d5dc54bae
https://github.com/openSUSE/open-build-service/commit/59a3142c6fbd2766ea3782...
Author: David Kang
Date: 2017-11-02 (Thu, 02 Nov 2017)
Changed paths:
M src/api/app/models/group.rb
M src/api/app/models/groups_user.rb
A src/api/db/migrate/20171102110929_disallow_null_for_group_id_in_groups_users.rb
M src/api/db/structure.sql
M src/api/spec/controllers/group_controller_spec.rb
Log Message:
-----------
Merge pull request #4041 from bgeuken/fix_user_group_destroy
[frontend] Fix deletion of groups_users
Compare: https://github.com/openSUSE/open-build-service/compare/f309ebca1020...59a314...