diff --git a/lib/graphiti/adapters/active_record.rb b/lib/graphiti/adapters/active_record.rb index 3cedfae6..37646aeb 100644 --- a/lib/graphiti/adapters/active_record.rb +++ b/lib/graphiti/adapters/active_record.rb @@ -38,6 +38,20 @@ def filter_not_eq(scope, attribute, value) alias_method :filter_uuid_not_eq, :filter_not_eq alias_method :filter_enum_not_eq, :filter_not_eq + def filter_array_eq(scope, attribute, value) + if value.is_a?(Array) + value = value.map(&:to_s).join(',') + end + scope.where("#{attribute} @> ?", "{ #{value} }") + end + + def filter_array_not_eq(scope, attribute, value) + if value.is_a?(Array) + value = value.map(&:to_s).join(',') + end + scope.where.not("#{attribute} @> ?", "{ #{value} }") + end + def filter_string_eq(scope, attribute, value, is_not: false) column = column_for(scope, attribute) clause = column.lower.eq_any(value.map(&:downcase))