Sha256: e5f65b639119e2898467aa9638e8ad9c75a100ee7044906d7a3bd9ccc58434c2

Contents?: true

Size: 710 Bytes

Versions: 6

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

module TableSaw
  module Queries
    class SerializeSqlInClause
      attr_reader :table_name, :column, :values

      def initialize(table_name, column, values)
        @table_name = table_name
        @column = column
        @values = values
      end

      def call
        "#{column} in (#{serialized_values.join(', ')})"
      end

      private

      def db_column
        TableSaw.schema_cache.columns_hash(table_name)[column]
      end

      def serialized_values
        values.map do |value|
          connection.quote_default_expression(value, db_column)
        end
      end

      def connection
        TableSaw::Connection.adapter
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
table_saw-3.1.0 lib/table_saw/queries/serialize_sql_in_clause.rb
table_saw-3.0.0 lib/table_saw/queries/serialize_sql_in_clause.rb
table_saw-2.10.0 lib/table_saw/queries/serialize_sql_in_clause.rb
table_saw-2.9.0 lib/table_saw/queries/serialize_sql_in_clause.rb
table_saw-2.8.1 lib/table_saw/queries/serialize_sql_in_clause.rb
table_saw-2.8.0 lib/table_saw/queries/serialize_sql_in_clause.rb