diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-20 13:36:18 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-20 13:40:25 +0200 |
commit | 9a3e4b8d1c197063bb832247657c8026f8ca307e (patch) | |
tree | e986421bf4de369cbff5f2e4bda71ec5b8afffcf /app/models/push_event.rb | |
parent | a09d032b2a64c7b6652dcd589de2d9bcba7d9613 (diff) | |
download | gitlab-ce-9a3e4b8d1c197063bb832247657c8026f8ca307e.tar.gz |
Remove redundant WHERE from event queriesevents-redundant-where
The default scope in Event would add a "WHERE author_id IS NOT NULL"
clause to every query. Now that "events.author_id" has a NOT NULL clause
set this filter is redundant and we can safely remove it.
In this commit we also add a validation on events.author_id (previously
only defined in PushEvent) just in case something tries to create data
without an author ID. This way we can present a nicer error message
compared to PostgreSQL's foreign key error messages.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/38129
Diffstat (limited to 'app/models/push_event.rb')
-rw-r--r-- | app/models/push_event.rb | 6 |
1 files changed, 0 insertions, 6 deletions
diff --git a/app/models/push_event.rb b/app/models/push_event.rb index 708513c7861..83ce9014094 100644 --- a/app/models/push_event.rb +++ b/app/models/push_event.rb @@ -3,12 +3,6 @@ class PushEvent < Event # different "action" value. validate :validate_push_action - # Authors are required as they're used to display who pushed data. - # - # We're just validating the presence of the ID here as foreign key constraints - # should ensure the ID points to a valid user. - validates :author_id, presence: true - # The project is required to build links to commits, commit ranges, etc. # # We're just validating the presence of the ID here as foreign key constraints |