diff options
author | Robert Speicher <robert@gitlab.com> | 2017-08-16 18:34:55 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-08-16 18:34:55 +0000 |
commit | ec34b2d051c16a351387fbaedb5542654810b8a5 (patch) | |
tree | e08e965390b86e187321d83957c99a45190a698a /config | |
parent | 72d5165bd57472692c77d6a9d159e65058513bf3 (diff) | |
parent | ba7251fefd92b0ecb6365cfe55510e24c5343ac6 (diff) | |
download | gitlab-ce-ec34b2d051c16a351387fbaedb5542654810b8a5.tar.gz |
Merge branch 'dm-gpg-signature-performance' into 'master'
Only create commit GPG signature when necessary
See merge request !13561
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/active_record_array_type_casting.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/config/initializers/active_record_array_type_casting.rb b/config/initializers/active_record_array_type_casting.rb new file mode 100644 index 00000000000..d94d592add6 --- /dev/null +++ b/config/initializers/active_record_array_type_casting.rb @@ -0,0 +1,20 @@ +module ActiveRecord + class PredicateBuilder + class ArrayHandler + module TypeCasting + def call(attribute, value) + # This is necessary because by default ActiveRecord does not respect + # custom type definitions (like our `ShaAttribute`) when providing an + # array in `where`, like in `where(commit_sha: [sha1, sha2, sha3])`. + model = attribute.relation&.engine + type = model.user_provided_columns[attribute.name] if model + value = value.map { |value| type.type_cast_for_database(value) } if type + + super(attribute, value) + end + end + + prepend TypeCasting + end + end +end |