7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/metka/query_builder/all_tags_query.rb', line 7
def call(model, column_name, tag_list)
column_cast = Arel::Nodes::NamedFunction.new(
"CAST",
[model.arel_table[column_name].as("text[]")]
)
value = Arel::Nodes::SqlLiteral.new(
ActiveRecord::Base.send(:sanitize_sql_for_conditions, ["ARRAY[?]", tag_list.to_a])
)
value_cast = Arel::Nodes::NamedFunction.new(
"CAST",
[value.as("text[]")]
)
Arel::Nodes::InfixOperation.new("@>", column_cast, value_cast)
end
|