activerecord-import 0.17.2 → 0.18.0
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/.travis.yml +7 -3
- data/CHANGELOG.md +15 -0
- data/Gemfile +1 -0
- data/README.markdown +1 -21
- data/gemfiles/5.1.gemfile +1 -0
- data/lib/activerecord-import/import.rb +79 -55
- data/lib/activerecord-import/version.rb +1 -1
- data/test/import_test.rb +44 -11
- data/test/models/tag.rb +1 -1
- data/test/models/topic.rb +1 -0
- data/test/schema/generic_schema.rb +10 -8
- data/test/schema/postgresql_schema.rb +1 -0
- data/test/support/postgresql/import_examples.rb +1 -1
- data/test/support/shared_examples/on_duplicate_key_ignore.rb +9 -7
- data/test/support/shared_examples/on_duplicate_key_update.rb +10 -8
- data/test/support/shared_examples/recursive_import.rb +12 -10
- data/test/test_helper.rb +6 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c586e3530cab4dd5f201737dd31c9634079ba1
|
4
|
+
data.tar.gz: 1eb5d9c977a304bbff53ce32ffd61a0620426cc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd502299bf521c3f9c6f98a2e4eb55ba8b88f0715401a7b959eedbfd26c0a455524642e3e76dbb429931fa006b519376a9be307daa12dd5b73e14f1c48ada29c
|
7
|
+
data.tar.gz: 6a980c019a2db629a2ba1772b6630119ac8a04da23dc06c091cdb378a75ceeaf37ad17e5104d7c51f2982cf0253ec6485a538327655aea2e0d29a480364549ce
|
data/.travis.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
|
-
- 2.
|
4
|
+
- 2.3.3
|
5
5
|
|
6
6
|
env:
|
7
7
|
global:
|
@@ -13,6 +13,7 @@ env:
|
|
13
13
|
- AR_VERSION=4.1
|
14
14
|
- AR_VERSION=4.2
|
15
15
|
- AR_VERSION=5.0
|
16
|
+
- AR_VERSION=5.1
|
16
17
|
|
17
18
|
matrix:
|
18
19
|
include:
|
@@ -26,6 +27,9 @@ matrix:
|
|
26
27
|
- bundle exec rake test:jdbcmysql
|
27
28
|
- bundle exec rake test:jdbcpostgresql
|
28
29
|
|
30
|
+
allow_failures:
|
31
|
+
- env: AR_VERSION=5.1
|
32
|
+
|
29
33
|
fast_finish: true
|
30
34
|
|
31
35
|
before_script:
|
@@ -37,7 +41,7 @@ before_script:
|
|
37
41
|
- cp test/travis/database.yml test/database.yml
|
38
42
|
|
39
43
|
addons:
|
40
|
-
postgresql: "9.
|
44
|
+
postgresql: "9.5"
|
41
45
|
apt:
|
42
46
|
sources:
|
43
47
|
- travis-ci/sqlite3
|
@@ -56,4 +60,4 @@ script:
|
|
56
60
|
- bundle exec rake test:sqlite3
|
57
61
|
- bundle exec rubocop
|
58
62
|
|
59
|
-
sudo:
|
63
|
+
sudo: required
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## Changes in 0.18.0
|
2
|
+
|
3
|
+
### New Features
|
4
|
+
|
5
|
+
* Uniqueness validation is bypassed when validating models since
|
6
|
+
it cannot be guaranteed if there are duplicates in a batch.
|
7
|
+
Thanks to @jkowens via \#301.
|
8
|
+
* Allow for custom timestamp columns. Thanks to @mojidabckuu, @jkowens
|
9
|
+
via \#401.
|
10
|
+
|
11
|
+
### Fixes
|
12
|
+
|
13
|
+
* Fix ActiveRecord 5 issue coercing boolean values when serializing
|
14
|
+
for the database. Thanks to @rjrobinson, @jkowens via \#403.
|
15
|
+
|
1
16
|
## Changes in 0.17.2
|
2
17
|
|
3
18
|
### Fixes
|
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -21,26 +21,6 @@ and then the reviews:
|
|
21
21
|
That would be about 4M SQL insert statements vs 3, which results in vastly improved performance. In our case, it converted
|
22
22
|
an 18 hour batch process to <2 hrs.
|
23
23
|
|
24
|
-
### Rails 5.0
|
25
|
-
|
26
|
-
Use activerecord-import 0.11.0 or higher.
|
27
|
-
|
28
|
-
### Rails 4.0
|
29
|
-
|
30
|
-
Use activerecord-import 0.4.0 or higher.
|
31
|
-
|
32
|
-
### Rails 3.2.x up to, but not including 4.0
|
33
|
-
|
34
|
-
Use activerecord-import 0.3.0 or higher.
|
35
|
-
|
36
|
-
### Rails 3.1.x up to, but not including 3.2
|
37
|
-
|
38
|
-
Use the latest in the activerecord-import 0.3.x series.
|
39
|
-
|
40
|
-
### Rails 3.0.x up to, but not including 3.1
|
41
|
-
|
42
|
-
Use activerecord-import 0.2.11. As of activerecord-import 0.3.0 we are relying on functionality that was introduced in Rails 3.1. Since Rails 3.0.x is no longer a supported version of Rails we have decided to drop support as well.
|
43
|
-
|
44
24
|
### More Information : Usage and Examples in Wiki
|
45
25
|
|
46
26
|
For more information on activerecord-import please see its wiki: https://github.com/zdennis/activerecord-import/wiki
|
@@ -54,7 +34,7 @@ When `ActiveRecord::Import.require_adapter("fake_name")` is called the require w
|
|
54
34
|
require 'activerecord-import/active_record/adapters/fake_name_adapter'
|
55
35
|
```
|
56
36
|
|
57
|
-
This allows an external gem to
|
37
|
+
This allows an external gem to dynamically add an adapter without the need to add any file/code to the core activerecord-import gem.
|
58
38
|
|
59
39
|
### Load Path Setup
|
60
40
|
To understand how rubygems loads code you can reference the following:
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'activerecord', '~> 5.1.0.rc1'
|
@@ -22,6 +22,44 @@ module ActiveRecord::Import #:nodoc:
|
|
22
22
|
super "Missing column for value <#{name}> at index #{index}"
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
class Validator
|
27
|
+
def initialize(validators, options = {})
|
28
|
+
@validators = validators
|
29
|
+
@options = options
|
30
|
+
end
|
31
|
+
|
32
|
+
def valid_model?(model)
|
33
|
+
validation_context = @options[:validate_with_context]
|
34
|
+
validation_context ||= (model.new_record? ? :create : :update)
|
35
|
+
|
36
|
+
current_context = model.send(:validation_context)
|
37
|
+
model.send(:validation_context=, validation_context)
|
38
|
+
model.errors.clear
|
39
|
+
|
40
|
+
@validators.each do |v|
|
41
|
+
if validation_context == v.options.fetch(:on, validation_context)
|
42
|
+
v.validate(model) if validate?(v, model)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
model.send(:validation_context=, current_context)
|
47
|
+
model.errors.empty?
|
48
|
+
end
|
49
|
+
|
50
|
+
def validate?(validator, model)
|
51
|
+
evaluate = lambda do |condition|
|
52
|
+
case condition
|
53
|
+
when String then model.instance_eval(condition)
|
54
|
+
when Symbol then model.send(condition)
|
55
|
+
when Proc then model.instance_eval(&condition)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
Array(validator.options[:if]).map(&evaluate).compact.all? &&
|
60
|
+
!Array(validator.options[:unless]).map(&evaluate).compact.any?
|
61
|
+
end
|
62
|
+
end
|
25
63
|
end
|
26
64
|
|
27
65
|
class ActiveRecord::Associations::CollectionProxy
|
@@ -97,19 +135,6 @@ end
|
|
97
135
|
|
98
136
|
class ActiveRecord::Base
|
99
137
|
class << self
|
100
|
-
# use tz as set in ActiveRecord::Base
|
101
|
-
tproc = lambda do
|
102
|
-
ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now
|
103
|
-
end
|
104
|
-
|
105
|
-
AREXT_RAILS_COLUMNS = {
|
106
|
-
create: { "created_on" => tproc,
|
107
|
-
"created_at" => tproc },
|
108
|
-
update: { "updated_on" => tproc,
|
109
|
-
"updated_at" => tproc }
|
110
|
-
}.freeze
|
111
|
-
AREXT_RAILS_COLUMN_NAMES = AREXT_RAILS_COLUMNS[:create].keys + AREXT_RAILS_COLUMNS[:update].keys
|
112
|
-
|
113
138
|
# Returns true if the current database connection adapter
|
114
139
|
# supports import functionality, otherwise returns false.
|
115
140
|
def supports_import?(*args)
|
@@ -453,10 +478,10 @@ class ActiveRecord::Base
|
|
453
478
|
|
454
479
|
return_obj = if is_validating
|
455
480
|
if models
|
456
|
-
import_with_validations( column_names, array_of_attributes, options ) do |failed|
|
481
|
+
import_with_validations( column_names, array_of_attributes, options ) do |validator, failed|
|
457
482
|
models.each_with_index do |model, i|
|
458
483
|
model = model.dup if options[:recursive]
|
459
|
-
next if
|
484
|
+
next if validator.valid_model? model
|
460
485
|
raise(ActiveRecord::RecordInvalid, model) if options[:raise_error]
|
461
486
|
array_of_attributes[i] = nil
|
462
487
|
failed << model
|
@@ -487,10 +512,6 @@ class ActiveRecord::Base
|
|
487
512
|
return_obj
|
488
513
|
end
|
489
514
|
|
490
|
-
# TODO import_from_table needs to be implemented.
|
491
|
-
def import_from_table( options ) # :nodoc:
|
492
|
-
end
|
493
|
-
|
494
515
|
# Imports the passed in +column_names+ and +array_of_attributes+
|
495
516
|
# given the passed in +options+ Hash with validations. Returns an
|
496
517
|
# object with the methods +failed_instances+ and +num_inserts+.
|
@@ -501,8 +522,11 @@ class ActiveRecord::Base
|
|
501
522
|
def import_with_validations( column_names, array_of_attributes, options = {} )
|
502
523
|
failed_instances = []
|
503
524
|
|
525
|
+
validators = self.validators.reject { |v| v.is_a? ActiveRecord::Validations::UniquenessValidator }
|
526
|
+
validator = ActiveRecord::Import::Validator.new(validators, options)
|
527
|
+
|
504
528
|
if block_given?
|
505
|
-
yield failed_instances
|
529
|
+
yield validator, failed_instances
|
506
530
|
else
|
507
531
|
# create instances for each of our column/value sets
|
508
532
|
arr = validations_array_for_column_names_and_attributes( column_names, array_of_attributes )
|
@@ -512,7 +536,7 @@ class ActiveRecord::Base
|
|
512
536
|
model = new
|
513
537
|
arr.each_with_index do |hsh, i|
|
514
538
|
hsh.each_pair { |k, v| model[k] = v }
|
515
|
-
next if
|
539
|
+
next if validator.valid_model? model
|
516
540
|
raise(ActiveRecord::RecordInvalid, model) if options[:raise_error]
|
517
541
|
array_of_attributes[i] = nil
|
518
542
|
failure = model.dup
|
@@ -671,7 +695,6 @@ class ActiveRecord::Base
|
|
671
695
|
# connection and type_caster get called a *lot* in this high intensity loop.
|
672
696
|
# Reuse the same ones w/in the loop, otherwise they would keep being re-retreived (= lots of time for large imports)
|
673
697
|
connection_memo = connection
|
674
|
-
type_caster_memo = type_caster if respond_to?(:type_caster)
|
675
698
|
|
676
699
|
array_of_attributes.map do |arr|
|
677
700
|
my_values = arr.each_with_index.map do |val, j|
|
@@ -681,11 +704,13 @@ class ActiveRecord::Base
|
|
681
704
|
if val.nil? && column.name == primary_key && !sequence_name.blank?
|
682
705
|
connection_memo.next_value_for_sequence(sequence_name)
|
683
706
|
elsif column
|
684
|
-
if
|
685
|
-
|
686
|
-
|
707
|
+
if respond_to?(:type_caster) # Rails 5.0 and higher
|
708
|
+
type = type_for_attribute(column.name)
|
709
|
+
val = type.type == :boolean ? type.cast(val) : type.serialize(val)
|
710
|
+
connection_memo.quote(val)
|
711
|
+
elsif column.respond_to?(:type_cast_from_user) # Rails 4.2
|
687
712
|
connection_memo.quote(column.type_cast_from_user(val), column)
|
688
|
-
else
|
713
|
+
else # Rails 3.2, 4.0 and 4.1
|
689
714
|
if serialized_attributes.include?(column.name)
|
690
715
|
val = serialized_attributes[column.name].dump(val)
|
691
716
|
end
|
@@ -698,39 +723,38 @@ class ActiveRecord::Base
|
|
698
723
|
end
|
699
724
|
|
700
725
|
def add_special_rails_stamps( column_names, array_of_attributes, options )
|
701
|
-
|
726
|
+
timestamp_columns = {}
|
727
|
+
timestamps = {}
|
702
728
|
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
# replace every instance of the array of attributes with our value
|
711
|
-
array_of_attributes.each { |arr| arr[index] = value if arr[index].nil? }
|
712
|
-
else
|
713
|
-
column_names << key
|
714
|
-
array_of_attributes.each { |arr| arr << value }
|
715
|
-
end
|
729
|
+
if respond_to?(:all_timestamp_attributes_in_model, true) # Rails 5.1 and higher
|
730
|
+
timestamp_columns[:create] = timestamp_attributes_for_create_in_model
|
731
|
+
timestamp_columns[:update] = timestamp_attributes_for_update_in_model
|
732
|
+
else
|
733
|
+
instance = new
|
734
|
+
timestamp_columns[:create] = instance.send(:timestamp_attributes_for_create_in_model)
|
735
|
+
timestamp_columns[:update] = instance.send(:timestamp_attributes_for_update_in_model)
|
716
736
|
end
|
717
737
|
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
738
|
+
# use tz as set in ActiveRecord::Base
|
739
|
+
timestamp = ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now
|
740
|
+
|
741
|
+
[:create, :update].each do |action|
|
742
|
+
timestamp_columns[action].each do |column|
|
743
|
+
column = column.to_s
|
744
|
+
timestamps[column] = timestamp
|
745
|
+
|
746
|
+
index = column_names.index(column) || column_names.index(column.to_sym)
|
747
|
+
if index
|
748
|
+
# replace every instance of the array of attributes with our value
|
749
|
+
array_of_attributes.each { |arr| arr[index] = timestamp if arr[index].nil? || action == :update }
|
750
|
+
else
|
751
|
+
column_names << column
|
752
|
+
array_of_attributes.each { |arr| arr << timestamp }
|
753
|
+
end
|
731
754
|
|
732
|
-
|
733
|
-
|
755
|
+
if supports_on_duplicate_key_update? && action == :update
|
756
|
+
connection.add_column_for_on_duplicate_key_update(column, options)
|
757
|
+
end
|
734
758
|
end
|
735
759
|
end
|
736
760
|
|
data/test/import_test.rb
CHANGED
@@ -88,21 +88,23 @@ describe "#import" do
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
unless ENV["SKIP_COMPOSITE_PK"]
|
92
|
+
describe "with composite primary keys" do
|
93
|
+
it "should import models successfully" do
|
94
|
+
tags = [Tag.new(tag_id: 1, publisher_id: 1, tag: 'Mystery')]
|
94
95
|
|
95
|
-
|
96
|
-
|
96
|
+
assert_difference "Tag.count", +1 do
|
97
|
+
Tag.import tags
|
98
|
+
end
|
97
99
|
end
|
98
|
-
end
|
99
100
|
|
100
|
-
|
101
|
-
|
102
|
-
|
101
|
+
it "should import array of values successfully" do
|
102
|
+
columns = [:tag_id, :publisher_id, :tag]
|
103
|
+
values = [[1, 1, 'Mystery'], [2, 1, 'Science']]
|
103
104
|
|
104
|
-
|
105
|
-
|
105
|
+
assert_difference "Tag.count", +2 do
|
106
|
+
Tag.import columns, values, validate: false
|
107
|
+
end
|
106
108
|
end
|
107
109
|
end
|
108
110
|
end
|
@@ -159,6 +161,13 @@ describe "#import" do
|
|
159
161
|
end
|
160
162
|
end
|
161
163
|
|
164
|
+
it "should ignore uniqueness validators" do
|
165
|
+
Topic.import columns, valid_values, validate: true
|
166
|
+
assert_difference "Topic.count", +2 do
|
167
|
+
Topic.import columns, valid_values, validate: true
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
162
171
|
it "should not import invalid data" do
|
163
172
|
assert_no_difference "Topic.count" do
|
164
173
|
Topic.import columns, invalid_values, validate: true
|
@@ -589,6 +598,30 @@ describe "#import" do
|
|
589
598
|
end
|
590
599
|
end
|
591
600
|
|
601
|
+
context 'importing arrays of values with boolean fields' do
|
602
|
+
let(:columns) { [:author_name, :title, :for_sale] }
|
603
|
+
|
604
|
+
it 'should be able to coerce integers as boolean fields' do
|
605
|
+
Book.delete_all if Book.count > 0
|
606
|
+
values = [['Author #1', 'Book #1', 0], ['Author #2', 'Book #2', 1]]
|
607
|
+
assert_difference "Book.count", +2 do
|
608
|
+
Book.import columns, values
|
609
|
+
end
|
610
|
+
assert_equal false, Book.first.for_sale
|
611
|
+
assert_equal true, Book.last.for_sale
|
612
|
+
end
|
613
|
+
|
614
|
+
it 'should be able to coerce strings as boolean fields' do
|
615
|
+
Book.delete_all if Book.count > 0
|
616
|
+
values = [['Author #1', 'Book #1', 'false'], ['Author #2', 'Book #2', 'true']]
|
617
|
+
assert_difference "Book.count", +2 do
|
618
|
+
Book.import columns, values
|
619
|
+
end
|
620
|
+
assert_equal false, Book.first.for_sale
|
621
|
+
assert_equal true, Book.last.for_sale
|
622
|
+
end
|
623
|
+
end
|
624
|
+
|
592
625
|
describe "importing when model has default_scope" do
|
593
626
|
it "doesn't import the default scope values" do
|
594
627
|
assert_difference "Widget.unscoped.count", +2 do
|
data/test/models/tag.rb
CHANGED
data/test/models/topic.rb
CHANGED
@@ -161,12 +161,14 @@ ActiveRecord::Schema.define do
|
|
161
161
|
|
162
162
|
add_index :cars, :Name, unique: true
|
163
163
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
164
|
+
unless ENV["SKIP_COMPOSITE_PK"]
|
165
|
+
execute %(
|
166
|
+
CREATE TABLE IF NOT EXISTS tags (
|
167
|
+
tag_id INT NOT NULL,
|
168
|
+
publisher_id INT NOT NULL,
|
169
|
+
tag VARCHAR(50),
|
170
|
+
PRIMARY KEY (tag_id, publisher_id)
|
171
|
+
);
|
172
|
+
).split.join(' ').strip
|
173
|
+
end
|
172
174
|
end
|
@@ -176,7 +176,7 @@ def should_support_postgresql_upsert_functionality
|
|
176
176
|
# would be associated with the wrong parent.
|
177
177
|
it ":on_duplicate_key_ignore is ignored" do
|
178
178
|
assert_raise ActiveRecord::RecordNotUnique do
|
179
|
-
Topic.import mixed_topics, recursive: true, on_duplicate_key_ignore: true
|
179
|
+
Topic.import mixed_topics, recursive: true, on_duplicate_key_ignore: true, validate: false
|
180
180
|
end
|
181
181
|
end
|
182
182
|
end
|
@@ -12,15 +12,17 @@ def should_support_on_duplicate_key_ignore
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
unless ENV["SKIP_COMPOSITE_PK"]
|
16
|
+
context "with composite primary keys" do
|
17
|
+
it "should import array of values successfully" do
|
18
|
+
columns = [:tag_id, :publisher_id, :tag]
|
19
|
+
values = [[1, 1, 'Mystery'], [1, 1, 'Science']]
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
assert_difference "Tag.count", +1 do
|
22
|
+
Tag.import columns, values, on_duplicate_key_ignore: true, validate: false
|
23
|
+
end
|
24
|
+
assert_equal 'Mystery', Tag.first.tag
|
22
25
|
end
|
23
|
-
assert_equal 'Mystery', Tag.first.tag
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -77,15 +77,17 @@ def should_support_basic_on_duplicate_key_update
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
Tag.
|
80
|
+
unless ENV["SKIP_COMPOSITE_PK"]
|
81
|
+
context "with composite primary keys" do
|
82
|
+
it "should import array of values successfully" do
|
83
|
+
columns = [:tag_id, :publisher_id, :tag]
|
84
|
+
Tag.import columns, [[1, 1, 'Mystery']], validate: false
|
85
|
+
|
86
|
+
assert_difference "Tag.count", +0 do
|
87
|
+
Tag.import columns, [[1, 1, 'Science']], on_duplicate_key_update: [:tag], validate: false
|
88
|
+
end
|
89
|
+
assert_equal 'Science', Tag.first.tag
|
87
90
|
end
|
88
|
-
assert_equal 'Science', Tag.first.tag
|
89
91
|
end
|
90
92
|
end
|
91
93
|
end
|
@@ -102,18 +102,20 @@ def should_support_recursive_import
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
unless ENV["SKIP_COMPOSITE_PK"]
|
106
|
+
describe "with composite primary keys" do
|
107
|
+
it "should import models and set id" do
|
108
|
+
tags = []
|
109
|
+
tags << Tag.new(tag_id: 1, publisher_id: 1, tag: 'Mystery')
|
110
|
+
tags << Tag.new(tag_id: 2, publisher_id: 1, tag: 'Science')
|
110
111
|
|
111
|
-
|
112
|
-
|
113
|
-
|
112
|
+
assert_difference "Tag.count", +2 do
|
113
|
+
Tag.import tags
|
114
|
+
end
|
114
115
|
|
115
|
-
|
116
|
-
|
116
|
+
assert_equal 1, tags[0].tag_id
|
117
|
+
assert_equal 2, tags[1].tag_id
|
118
|
+
end
|
117
119
|
end
|
118
120
|
end
|
119
121
|
|
data/test/test_helper.rb
CHANGED
@@ -26,7 +26,12 @@ end
|
|
26
26
|
|
27
27
|
require 'timecop'
|
28
28
|
require 'chronic'
|
29
|
-
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'composite_primary_keys'
|
32
|
+
rescue LoadError
|
33
|
+
ENV["SKIP_COMPOSITE_PK"] = "true"
|
34
|
+
end
|
30
35
|
|
31
36
|
require "ruby-debug" if RUBY_VERSION.to_f < 1.9
|
32
37
|
|
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.
|
4
|
+
version: 0.18.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: 2017-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- gemfiles/4.1.gemfile
|
74
74
|
- gemfiles/4.2.gemfile
|
75
75
|
- gemfiles/5.0.gemfile
|
76
|
+
- gemfiles/5.1.gemfile
|
76
77
|
- lib/activerecord-import.rb
|
77
78
|
- lib/activerecord-import/active_record/adapters/abstract_adapter.rb
|
78
79
|
- lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb
|
@@ -175,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
176
|
version: '0'
|
176
177
|
requirements: []
|
177
178
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.6.
|
179
|
+
rubygems_version: 2.6.11
|
179
180
|
signing_key:
|
180
181
|
specification_version: 4
|
181
182
|
summary: Bulk insert extension for ActiveRecord
|