Module: ActiveRecord::Jdbc::Import

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_record/jdbc/import.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#to_prepared_sqlObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/active_record/jdbc/import.rb', line 58

def to_prepared_sql
  conn = self.connection
  
  quoted_columns = []
  quoted_values = []
  attributes_with_values = self.send(:arel_attributes_values, true, true)
  attributes_with_values.each_pair do |key,value|
    next if key.name.to_s == 'id'
    quoted_columns << conn.quote_column_name(key.name)
    quoted_values << '?'
  end
  
  "INSERT INTO #{self.class.quoted_table_name} " +
    "(#{quoted_columns.join(', ')}) "  +
    "VALUES (#{quoted_values.join(', ')});"
end