Sha256: db13514a4965ce4d08c777d7607e9721f05674c102067bd788d2e24dbeeb856d

Contents?: true

Size: 989 Bytes

Versions: 3

Compression:

Stored size: 989 Bytes

Contents

module MassInsert
  module Adapters
    class SQLServerAdapter < Adapter

      MAX_VALUES_PER_INSERTION = 1000

      # This method is overwrite because the timestamp format to this
      # database engine needs precision in three nanoseconds.
      def timestamp_format
        "%Y-%m-%d %H:%M:%S.%3N"
      end

      # This functions calls the necessary functions to create a complete
      # sqlserver query to multiple insertion. The methods are in the Abstract
      # Query module. If some method is too specific to this database adapter
      # you can overwrite it. The values that the user gave will be treated
      # in batches of 500 items because sqlite database allows by default
      # batches of 500.and each batch will generate a query. This method will
      # generate an array with batch queries.
      def execute
        @values.each_slice(MAX_VALUES_PER_INSERTION).map do |slice|
          @values = slice
          super
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mass_insert-0.1.1 lib/mass_insert/adapters/sqlserver_adapter.rb
mass_insert-0.1.0 lib/mass_insert/adapters/sqlserver_adapter.rb
mass_insert-0.0.4 lib/mass_insert/adapters/sqlserver_adapter.rb