Class: MassInsert::Builder::Adapters::SQLServerAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/mass_insert/builder/adapters/sqlserver_adapter.rb

Instance Attribute Summary

Attributes inherited from Adapter

#options, #values

Instance Method Summary collapse

Methods inherited from Adapter

#columns, #initialize, #method_missing, #sanitized_columns, #timestamp, #timestamp?, #timestamp_hash

Methods included from Helpers::AbstractQuery

#begin_string, #execute, #string_rows_values, #string_single_row_values, #string_single_value, #string_values

Constructor Details

This class inherits a constructor from MassInsert::Builder::Adapters::Adapter

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MassInsert::Builder::Adapters::Adapter

Instance Method Details

#string_columnsObject

Returns a basic part of the query with the columns definition.



7
8
9
# File 'lib/mass_insert/builder/adapters/sqlserver_adapter.rb', line 7

def string_columns
  "([#{columns.join("], [")}]) "
end

#timestamp_formatObject

The method is overwrited because the timestamp format to SQLServer adapter needs accuracy with three nanoseconds.



19
20
21
# File 'lib/mass_insert/builder/adapters/sqlserver_adapter.rb', line 19

def timestamp_format
  "%Y-%m-%d %H:%M:%S.%3N"
end

#values_per_insertionObject

Returns the amount of records to each query. Tries to take the each_slice option value or 1000 due it’s a standard in SQLServer.



13
14
15
# File 'lib/mass_insert/builder/adapters/sqlserver_adapter.rb', line 13

def values_per_insertion
  each_slice || 1000
end