Skip to content

Commit

Permalink
Add build_quoted to AR backend class methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shioyama committed Apr 29, 2018
1 parent b23d0a5 commit a0d9c7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/mobility/backends/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def add_scope(relation, _opts, _locale, _invert, _backend_options)
def collapse(value)
value.is_a?(Array) ? value.uniq : value
end

def build_quoted(value)
::Arel::Nodes.build_quoted(value)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backends/active_record/jsonb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def self.build_node(attr, locale, model_class:, column_affix:, **)
end

def self.build_predicate(attr, locale, values, backend_options)
json_values = Array.wrap(values).map { |value| value && ::Arel::Nodes.build_quoted(value.to_json) }
json_values = Array.wrap(values).map { |value| value && build_quoted(value.to_json) }
super(attr, locale, json_values, backend_options)
end

Expand Down

0 comments on commit a0d9c7a

Please sign in to comment.