diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-08-15 13:22:55 +0200 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-08-16 18:57:50 +0200 |
commit | ba7251fefd92b0ecb6365cfe55510e24c5343ac6 (patch) | |
tree | d572877f0150efa654849b97896ef769aeff6c0b /config | |
parent | 4a2a6d521a260981482ee8e4931ebf06cb4f5b6a (diff) | |
download | gitlab-ce-ba7251fefd92b0ecb6365cfe55510e24c5343ac6.tar.gz |
Only create commit GPG signature when necessarydm-gpg-signature-performance
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 |