Sha256: 7f2236b8b3c91bab185756bccef020681980532278b7efbca6691066d354087e
Contents?: true
Size: 744 Bytes
Versions: 1
Compression:
Stored size: 744 Bytes
Contents
# frozen_string_literal: true require 'singleton' module Metka class BaseQuery include Singleton 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( # In Rails 5.2 and above Sanitanization moved to public level, but still we have to support 4.2 and 5.0 and 5.1 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(infix_operator, column_cast, value_cast) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
metka-2.1.0 | lib/metka/query_builder/base_query.rb |