Sha256: 97e79eb09b64e9cbe3e6ce8ed92e33de09202605748c7081d1597b7a7eec20f6

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 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|
          TableSaw.connection.quote_default_expression(value, db_column)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
table_saw-3.2.0 lib/table_saw/queries/serialize_sql_in_clause.rb