method
new
Ruby on Rails latest stable (v7.1.3.2)
-
0 notes -
Class: InsertAll
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
new(model, inserts, on_duplicate:, update_only: nil, returning: nil, unique_by: nil, record_timestamps: nil)
public
Hide source
# File activerecord/lib/active_record/insert_all.rb, line 10 def initialize(model, inserts, on_duplicate,, update_only: nil, returning: nil, unique_by: nil, record_timestamps: nil) @model, @connection, @inserts = model, model.connection, inserts.map(&:stringify_keys) @on_duplicate, @update_only, @returning, @unique_by = on_duplicate, update_only, returning, unique_by @record_timestamps = record_timestamps.nil? ? model.record_timestamps : record_timestamps disallow_raw_sql!(on_duplicate) disallow_raw_sql!(returning) if @inserts.empty? @keys = [] else resolve_sti resolve_attribute_aliases @keys = @inserts.first.keys end if model.scope_attributes? @scope_attributes = model.scope_attributes @keys |= @scope_attributes.keys end @keys = @keys.to_set @returning = (connection.supports_insert_returning? ? primary_keys : false) if @returning.nil? @returning = false if @returning == [] @unique_by = find_unique_index_for(@unique_by) configure_on_duplicate_update_logic ensure_valid_options_for_connection! end