Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-08-15 14:22:55 +0300
committerDouwe Maan <douwe@selenight.nl>2017-08-16 19:57:50 +0300
commitba7251fefd92b0ecb6365cfe55510e24c5343ac6 (patch)
treed572877f0150efa654849b97896ef769aeff6c0b /config
parent4a2a6d521a260981482ee8e4931ebf06cb4f5b6a (diff)
Only create commit GPG signature when necessary
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