Class: ProjectAuthorization

Inherits:
ApplicationRecord show all
Extended by:
SuppressCompositePrimaryKeyWarning
Includes:
FromUnion
Defined in:
app/models/project_authorization.rb

Constant Summary

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Class Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.insert_all(attributes) ⇒ Object

This method overrides its ActiveRecord’s version in order to work correctly with composite primary keys and fix the tests for Rails 6.1

Consider using BulkInsertSafe module instead since we plan to refactor it in gitlab.com/gitlab-org/gitlab/-/issues/331264



30
31
32
# File 'app/models/project_authorization.rb', line 30

def self.insert_all(attributes)
  super(attributes, unique_by: connection.schema_cache.primary_keys(table_name))
end

.select_from_union(relations) ⇒ Object



19
20
21
22
23
# File 'app/models/project_authorization.rb', line 19

def self.select_from_union(relations)
  from_union(relations)
    .select(['project_id', 'MAX(access_level) AS access_level'])
    .group(:project_id)
end