activerecord-import 0.18.2 → 0.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/activerecord-import/import.rb +12 -8
- data/lib/activerecord-import/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32bb7874255a2f1979d7fc370e46c9c614c362df
|
4
|
+
data.tar.gz: 7b45f6b4f22e64c032d320b34fa0989af63fb4aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdba083a35bde877674eaadb6bccd5cb83d285370926ef8ca557f0fe3cef08912d011599513ef640f0e1f5bd3dcfd9d0bb0a6979040d08ae1424118035ef93b4
|
7
|
+
data.tar.gz: 570dc7bb80545e93cb00114ddf2f09795b410b402e3ba5cd3c3023fc18e974b53d7fc0b78a684440707b7fc7d9163fba84ea8df077d0a7214d2b0eb0556563df
|
data/CHANGELOG.md
CHANGED
@@ -521,9 +521,7 @@ class ActiveRecord::Base
|
|
521
521
|
|
522
522
|
# if we have ids, then set the id on the models and mark the models as clean.
|
523
523
|
if models && support_setting_primary_key_of_imported_objects?
|
524
|
-
|
525
|
-
set_attributes_and_mark_clean(models, return_obj, timestamps)
|
526
|
-
end
|
524
|
+
set_attributes_and_mark_clean(models, return_obj, timestamps)
|
527
525
|
|
528
526
|
# if there are auto-save associations on the models we imported that are new, import them as well
|
529
527
|
import_associations(models, options.dup) if options[:recursive]
|
@@ -643,18 +641,24 @@ class ActiveRecord::Base
|
|
643
641
|
def set_attributes_and_mark_clean(models, import_result, timestamps)
|
644
642
|
return if models.nil?
|
645
643
|
models -= import_result.failed_instances
|
646
|
-
|
647
|
-
model = models[index]
|
648
|
-
model.id = id
|
644
|
+
models.each do |model|
|
649
645
|
if model.respond_to?(:clear_changes_information) # Rails 4.0 and higher
|
650
646
|
model.clear_changes_information
|
651
647
|
else # Rails 3.2
|
652
648
|
model.instance_variable_get(:@changed_attributes).clear
|
653
649
|
end
|
654
650
|
model.instance_variable_set(:@new_record, false)
|
651
|
+
end
|
655
652
|
|
656
|
-
|
657
|
-
|
653
|
+
# if ids were returned for all models we know all were updated
|
654
|
+
if models.size == import_result.ids.size
|
655
|
+
import_result.ids.each_with_index do |id, index|
|
656
|
+
model = models[index]
|
657
|
+
model.id = id
|
658
|
+
|
659
|
+
timestamps.each do |attr, value|
|
660
|
+
model.send(attr + "=", value)
|
661
|
+
end
|
658
662
|
end
|
659
663
|
end
|
660
664
|
end
|
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.18.
|
4
|
+
version: 0.18.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|