summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-08-16 18:34:55 +0000
committerRobert Speicher <robert@gitlab.com>2017-08-16 18:34:55 +0000
commitec34b2d051c16a351387fbaedb5542654810b8a5 (patch)
treee08e965390b86e187321d83957c99a45190a698a /config
parent72d5165bd57472692c77d6a9d159e65058513bf3 (diff)
parentba7251fefd92b0ecb6365cfe55510e24c5343ac6 (diff)
downloadgitlab-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.rb20
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