activerecord-import 0.28.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 39f2e5b83b07075c09bba10e3c9a53953b484641
4
- data.tar.gz: 28869f9586c6200e932a34dadbed9f4790ee820d
2
+ SHA256:
3
+ metadata.gz: 8f5ca21d97ac6550f23697bb50649a0e3c04858e922b9e0c9034201b38eaeba9
4
+ data.tar.gz: be99806f9a678aa8be4c9d06c904625ae49cab5be519dfced6300deab00adfe0
5
5
  SHA512:
6
- metadata.gz: dad31c1f3f11c1b6ba63cf2c5e65d71713603cb7604cac06e35d2786f34394e88a2ad69bc76fcaf14d7cd90e84fa277e84427425aa27cd0bcb65c61024990e1a
7
- data.tar.gz: e842906754fd995d1be896e7929213919426ccf9c107f06c996c0216b9331c3232ff85ceb622c9de4678de6ff639e22ee783c5482bb9fbdb8c5740df46d55304
6
+ metadata.gz: 749c050502f6b5edab4f46dcb6f8048bb652a825287278698b30328001a1d8be2eee4d68e1dc98b0d581c1ef090c957b2aa6918e43ca094818316c478c499c9b
7
+ data.tar.gz: 554e93c8bd7693852f25a9fa777757d22a53a48d3e24fc98e9a44bcb2daa946d9b39eb4dabb8f20063dc48a17717cb91e3f5a0870c95c04557b605108868c2cf
@@ -1,3 +1,18 @@
1
+ ## Changes in 1.0.0
2
+
3
+ ### New Features
4
+
5
+ * Move ActiveRecord::Dirty changes to previous_changes after import.
6
+ Thanks to @stokarenko via \#584.
7
+
8
+ ### Breaking Changes
9
+
10
+ * Previously :on_duplicate_key_update was enabled by default for MySQL.
11
+ The update timestamp columns (updated_at, updated_on) would be updated
12
+ on duplicate key. This was behavior is inconsistent with the other database
13
+ adapters and could also be considered surprising. Going forward it must
14
+ be explicitly enabled. See \#548.
15
+
1
16
  ## Changes in 0.28.2
2
17
 
3
18
  ### Fixes
@@ -113,7 +113,7 @@ Book.import values, validate: true
113
113
  # when not specified :validate defaults to true
114
114
  Book.import values
115
115
  ```
116
- h2. Import Using Hashes and Explicit Column Names
116
+ #### Import Using Hashes and Explicit Column Names
117
117
 
118
118
  The `import` method can take an array of column names and an array of hash objects. The column names are used to determine what fields of data should be imported. The following example will only import books with the `title` field:
119
119
 
@@ -71,14 +71,11 @@ module ActiveRecord::Import::MysqlAdapter
71
71
 
72
72
  # Add a column to be updated on duplicate key update
73
73
  def add_column_for_on_duplicate_key_update( column, options = {} ) # :nodoc:
74
- if options.include?(:on_duplicate_key_update)
75
- columns = options[:on_duplicate_key_update]
74
+ if (columns = options[:on_duplicate_key_update])
76
75
  case columns
77
76
  when Array then columns << column.to_sym unless columns.include?(column.to_sym)
78
77
  when Hash then columns[column.to_sym] = column.to_sym
79
78
  end
80
- elsif !options[:ignore] && !options[:on_duplicate_key_ignore]
81
- options[:on_duplicate_key_update] = [column.to_sym]
82
79
  end
83
80
  end
84
81
 
@@ -868,7 +868,10 @@ class ActiveRecord::Base
868
868
  end
869
869
 
870
870
  models.each do |model|
871
- if model.respond_to?(:clear_changes_information) # Rails 4.0 and higher
871
+ if model.respond_to?(:changes_applied) # Rails 4.1.8 and higher
872
+ model.changes_internally_applied if model.respond_to?(:changes_internally_applied) # legacy behavior for Rails 5.1
873
+ model.changes_applied
874
+ elsif model.respond_to?(:clear_changes_information) # Rails 4.0 and higher
872
875
  model.clear_changes_information
873
876
  else # Rails 3.2
874
877
  model.instance_variable_get(:@changed_attributes).clear
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Import
3
- VERSION = "0.28.2".freeze
3
+ VERSION = "1.0.0".freeze
4
4
  end
5
5
  end
@@ -37,6 +37,12 @@ def should_support_postgresql_import_functionality
37
37
  assert !topic.changed?
38
38
  end
39
39
 
40
+ if ENV['AR_VERSION'].to_f > 4.1
41
+ it "moves the dirty changes to previous_changes" do
42
+ assert topic.previous_changes.present?
43
+ end
44
+ end
45
+
40
46
  it "marks models as persisted" do
41
47
  assert !topic.new_record?
42
48
  assert topic.persisted?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-import
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Dennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-29 00:00:00.000000000 Z
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.6.11
187
+ rubygems_version: 2.7.7
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Bulk insert extension for ActiveRecord