mass_insert 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +10 -20
- data/.travis.yml +17 -10
- data/Appraisals +4 -8
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +0 -6
- data/LICENSE.txt +17 -18
- data/README.md +39 -27
- data/Rakefile +3 -3
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gemfiles/rails_5.2.gemfile +0 -3
- data/gemfiles/rails_5.2.gemfile.lock +82 -89
- data/gemfiles/{rails_4.gemfile → rails_6.0.gemfile} +1 -4
- data/gemfiles/rails_6.0.gemfile.lock +171 -0
- data/lib/mass_insert/version.rb +1 -1
- data/mass_insert.gemspec +19 -12
- metadata +61 -57
- data/.rspec +0 -1
- data/gemfiles/rails_4.gemfile.lock +0 -147
- data/gemfiles/rails_5.gemfile +0 -10
- data/gemfiles/rails_5.gemfile.lock +0 -162
- data/test/adapters/mysql2/example_test.rb +0 -29
- data/test/adapters/postgresql/example_test.rb +0 -3
- data/test/adapters/sqlite3/example_test.rb +0 -3
- data/test/database.yml.example +0 -20
- data/test/models/kind.rb +0 -2
- data/test/models/post.rb +0 -2
- data/test/models/user.rb +0 -2
- data/test/schema.rb +0 -20
- data/test/support/adapters/mysql2.rb +0 -1
- data/test/support/adapters/postgresql.rb +0 -1
- data/test/support/adapters/sqlite3.rb +0 -1
- data/test/support/shared_examples.rb +0 -90
- data/test/test_helper.rb +0 -36
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
@@ -1,147 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
mass_insert (0.2.6)
|
5
|
-
activerecord (>= 4.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actionmailer (4.2.10)
|
11
|
-
actionpack (= 4.2.10)
|
12
|
-
actionview (= 4.2.10)
|
13
|
-
activejob (= 4.2.10)
|
14
|
-
mail (~> 2.5, >= 2.5.4)
|
15
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
-
actionpack (4.2.10)
|
17
|
-
actionview (= 4.2.10)
|
18
|
-
activesupport (= 4.2.10)
|
19
|
-
rack (~> 1.6)
|
20
|
-
rack-test (~> 0.6.2)
|
21
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
23
|
-
actionview (4.2.10)
|
24
|
-
activesupport (= 4.2.10)
|
25
|
-
builder (~> 3.1)
|
26
|
-
erubis (~> 2.7.0)
|
27
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
28
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
29
|
-
activejob (4.2.10)
|
30
|
-
activesupport (= 4.2.10)
|
31
|
-
globalid (>= 0.3.0)
|
32
|
-
activemodel (4.2.10)
|
33
|
-
activesupport (= 4.2.10)
|
34
|
-
builder (~> 3.1)
|
35
|
-
activerecord (4.2.10)
|
36
|
-
activemodel (= 4.2.10)
|
37
|
-
activesupport (= 4.2.10)
|
38
|
-
arel (~> 6.0)
|
39
|
-
activesupport (4.2.10)
|
40
|
-
i18n (~> 0.7)
|
41
|
-
minitest (~> 5.1)
|
42
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
43
|
-
tzinfo (~> 1.1)
|
44
|
-
appraisal (2.2.0)
|
45
|
-
bundler
|
46
|
-
rake
|
47
|
-
thor (>= 0.14.0)
|
48
|
-
arel (6.0.4)
|
49
|
-
builder (3.2.3)
|
50
|
-
concurrent-ruby (1.0.5)
|
51
|
-
coveralls (0.7.2)
|
52
|
-
multi_json (~> 1.3)
|
53
|
-
rest-client (= 1.6.7)
|
54
|
-
simplecov (>= 0.7)
|
55
|
-
term-ansicolor (= 1.2.2)
|
56
|
-
thor (= 0.18.1)
|
57
|
-
crass (1.0.4)
|
58
|
-
docile (1.3.0)
|
59
|
-
erubis (2.7.0)
|
60
|
-
globalid (0.4.1)
|
61
|
-
activesupport (>= 4.2.0)
|
62
|
-
i18n (0.9.5)
|
63
|
-
concurrent-ruby (~> 1.0)
|
64
|
-
json (2.1.0)
|
65
|
-
loofah (2.2.2)
|
66
|
-
crass (~> 1.0.2)
|
67
|
-
nokogiri (>= 1.5.9)
|
68
|
-
mail (2.7.0)
|
69
|
-
mini_mime (>= 0.1.1)
|
70
|
-
mime-types (3.1)
|
71
|
-
mime-types-data (~> 3.2015)
|
72
|
-
mime-types-data (3.2016.0521)
|
73
|
-
mini_mime (1.0.0)
|
74
|
-
mini_portile2 (2.3.0)
|
75
|
-
minitest (5.11.3)
|
76
|
-
multi_json (1.13.1)
|
77
|
-
mysql2 (0.5.1)
|
78
|
-
nokogiri (1.8.2)
|
79
|
-
mini_portile2 (~> 2.3.0)
|
80
|
-
pg (0.21.0)
|
81
|
-
rack (1.6.10)
|
82
|
-
rack-test (0.6.3)
|
83
|
-
rack (>= 1.0)
|
84
|
-
rails (4.2.10)
|
85
|
-
actionmailer (= 4.2.10)
|
86
|
-
actionpack (= 4.2.10)
|
87
|
-
actionview (= 4.2.10)
|
88
|
-
activejob (= 4.2.10)
|
89
|
-
activemodel (= 4.2.10)
|
90
|
-
activerecord (= 4.2.10)
|
91
|
-
activesupport (= 4.2.10)
|
92
|
-
bundler (>= 1.3.0, < 2.0)
|
93
|
-
railties (= 4.2.10)
|
94
|
-
sprockets-rails
|
95
|
-
rails-deprecated_sanitizer (1.0.3)
|
96
|
-
activesupport (>= 4.2.0.alpha)
|
97
|
-
rails-dom-testing (1.0.9)
|
98
|
-
activesupport (>= 4.2.0, < 5.0)
|
99
|
-
nokogiri (~> 1.6)
|
100
|
-
rails-deprecated_sanitizer (>= 1.0.1)
|
101
|
-
rails-html-sanitizer (1.0.4)
|
102
|
-
loofah (~> 2.2, >= 2.2.2)
|
103
|
-
railties (4.2.10)
|
104
|
-
actionpack (= 4.2.10)
|
105
|
-
activesupport (= 4.2.10)
|
106
|
-
rake (>= 0.8.7)
|
107
|
-
thor (>= 0.18.1, < 2.0)
|
108
|
-
rake (11.3.0)
|
109
|
-
rest-client (1.6.7)
|
110
|
-
mime-types (>= 1.16)
|
111
|
-
simplecov (0.16.1)
|
112
|
-
docile (~> 1.1)
|
113
|
-
json (>= 1.8, < 3)
|
114
|
-
simplecov-html (~> 0.10.0)
|
115
|
-
simplecov-html (0.10.2)
|
116
|
-
sprockets (3.7.1)
|
117
|
-
concurrent-ruby (~> 1.0)
|
118
|
-
rack (> 1, < 3)
|
119
|
-
sprockets-rails (3.2.1)
|
120
|
-
actionpack (>= 4.0)
|
121
|
-
activesupport (>= 4.0)
|
122
|
-
sprockets (>= 3.0.0)
|
123
|
-
sqlite3 (1.3.13)
|
124
|
-
term-ansicolor (1.2.2)
|
125
|
-
tins (~> 0.8)
|
126
|
-
thor (0.18.1)
|
127
|
-
thread_safe (0.3.6)
|
128
|
-
tins (0.13.2)
|
129
|
-
tzinfo (1.2.5)
|
130
|
-
thread_safe (~> 0.1)
|
131
|
-
|
132
|
-
PLATFORMS
|
133
|
-
ruby
|
134
|
-
|
135
|
-
DEPENDENCIES
|
136
|
-
appraisal
|
137
|
-
coveralls
|
138
|
-
mass_insert!
|
139
|
-
mysql2 (~> 0.4)
|
140
|
-
pg (~> 0.18)
|
141
|
-
rails (~> 4.2)
|
142
|
-
rake (~> 11.1)
|
143
|
-
simplecov
|
144
|
-
sqlite3 (~> 1.3)
|
145
|
-
|
146
|
-
BUNDLED WITH
|
147
|
-
1.16.2
|
data/gemfiles/rails_5.gemfile
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
mass_insert (0.2.6)
|
5
|
-
activerecord (>= 4.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actioncable (5.2.0)
|
11
|
-
actionpack (= 5.2.0)
|
12
|
-
nio4r (~> 2.0)
|
13
|
-
websocket-driver (>= 0.6.1)
|
14
|
-
actionmailer (5.2.0)
|
15
|
-
actionpack (= 5.2.0)
|
16
|
-
actionview (= 5.2.0)
|
17
|
-
activejob (= 5.2.0)
|
18
|
-
mail (~> 2.5, >= 2.5.4)
|
19
|
-
rails-dom-testing (~> 2.0)
|
20
|
-
actionpack (5.2.0)
|
21
|
-
actionview (= 5.2.0)
|
22
|
-
activesupport (= 5.2.0)
|
23
|
-
rack (~> 2.0)
|
24
|
-
rack-test (>= 0.6.3)
|
25
|
-
rails-dom-testing (~> 2.0)
|
26
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
-
actionview (5.2.0)
|
28
|
-
activesupport (= 5.2.0)
|
29
|
-
builder (~> 3.1)
|
30
|
-
erubi (~> 1.4)
|
31
|
-
rails-dom-testing (~> 2.0)
|
32
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
-
activejob (5.2.0)
|
34
|
-
activesupport (= 5.2.0)
|
35
|
-
globalid (>= 0.3.6)
|
36
|
-
activemodel (5.2.0)
|
37
|
-
activesupport (= 5.2.0)
|
38
|
-
activerecord (5.2.0)
|
39
|
-
activemodel (= 5.2.0)
|
40
|
-
activesupport (= 5.2.0)
|
41
|
-
arel (>= 9.0)
|
42
|
-
activestorage (5.2.0)
|
43
|
-
actionpack (= 5.2.0)
|
44
|
-
activerecord (= 5.2.0)
|
45
|
-
marcel (~> 0.3.1)
|
46
|
-
activesupport (5.2.0)
|
47
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
48
|
-
i18n (>= 0.7, < 2)
|
49
|
-
minitest (~> 5.1)
|
50
|
-
tzinfo (~> 1.1)
|
51
|
-
appraisal (2.2.0)
|
52
|
-
bundler
|
53
|
-
rake
|
54
|
-
thor (>= 0.14.0)
|
55
|
-
arel (9.0.0)
|
56
|
-
builder (3.2.3)
|
57
|
-
concurrent-ruby (1.0.5)
|
58
|
-
coveralls (0.7.2)
|
59
|
-
multi_json (~> 1.3)
|
60
|
-
rest-client (= 1.6.7)
|
61
|
-
simplecov (>= 0.7)
|
62
|
-
term-ansicolor (= 1.2.2)
|
63
|
-
thor (= 0.18.1)
|
64
|
-
crass (1.0.4)
|
65
|
-
docile (1.3.0)
|
66
|
-
erubi (1.7.1)
|
67
|
-
globalid (0.4.1)
|
68
|
-
activesupport (>= 4.2.0)
|
69
|
-
i18n (1.0.1)
|
70
|
-
concurrent-ruby (~> 1.0)
|
71
|
-
json (2.1.0)
|
72
|
-
loofah (2.2.2)
|
73
|
-
crass (~> 1.0.2)
|
74
|
-
nokogiri (>= 1.5.9)
|
75
|
-
mail (2.7.0)
|
76
|
-
mini_mime (>= 0.1.1)
|
77
|
-
marcel (0.3.2)
|
78
|
-
mimemagic (~> 0.3.2)
|
79
|
-
method_source (0.9.0)
|
80
|
-
mime-types (3.1)
|
81
|
-
mime-types-data (~> 3.2015)
|
82
|
-
mime-types-data (3.2016.0521)
|
83
|
-
mimemagic (0.3.2)
|
84
|
-
mini_mime (1.0.0)
|
85
|
-
mini_portile2 (2.3.0)
|
86
|
-
minitest (5.11.3)
|
87
|
-
multi_json (1.13.1)
|
88
|
-
mysql2 (0.5.1)
|
89
|
-
nio4r (2.3.1)
|
90
|
-
nokogiri (1.8.2)
|
91
|
-
mini_portile2 (~> 2.3.0)
|
92
|
-
pg (0.21.0)
|
93
|
-
rack (2.0.5)
|
94
|
-
rack-test (1.0.0)
|
95
|
-
rack (>= 1.0, < 3)
|
96
|
-
rails (5.2.0)
|
97
|
-
actioncable (= 5.2.0)
|
98
|
-
actionmailer (= 5.2.0)
|
99
|
-
actionpack (= 5.2.0)
|
100
|
-
actionview (= 5.2.0)
|
101
|
-
activejob (= 5.2.0)
|
102
|
-
activemodel (= 5.2.0)
|
103
|
-
activerecord (= 5.2.0)
|
104
|
-
activestorage (= 5.2.0)
|
105
|
-
activesupport (= 5.2.0)
|
106
|
-
bundler (>= 1.3.0)
|
107
|
-
railties (= 5.2.0)
|
108
|
-
sprockets-rails (>= 2.0.0)
|
109
|
-
rails-dom-testing (2.0.3)
|
110
|
-
activesupport (>= 4.2.0)
|
111
|
-
nokogiri (>= 1.6)
|
112
|
-
rails-html-sanitizer (1.0.4)
|
113
|
-
loofah (~> 2.2, >= 2.2.2)
|
114
|
-
railties (5.2.0)
|
115
|
-
actionpack (= 5.2.0)
|
116
|
-
activesupport (= 5.2.0)
|
117
|
-
method_source
|
118
|
-
rake (>= 0.8.7)
|
119
|
-
thor (>= 0.18.1, < 2.0)
|
120
|
-
rake (11.3.0)
|
121
|
-
rest-client (1.6.7)
|
122
|
-
mime-types (>= 1.16)
|
123
|
-
simplecov (0.16.1)
|
124
|
-
docile (~> 1.1)
|
125
|
-
json (>= 1.8, < 3)
|
126
|
-
simplecov-html (~> 0.10.0)
|
127
|
-
simplecov-html (0.10.2)
|
128
|
-
sprockets (3.7.1)
|
129
|
-
concurrent-ruby (~> 1.0)
|
130
|
-
rack (> 1, < 3)
|
131
|
-
sprockets-rails (3.2.1)
|
132
|
-
actionpack (>= 4.0)
|
133
|
-
activesupport (>= 4.0)
|
134
|
-
sprockets (>= 3.0.0)
|
135
|
-
sqlite3 (1.3.13)
|
136
|
-
term-ansicolor (1.2.2)
|
137
|
-
tins (~> 0.8)
|
138
|
-
thor (0.18.1)
|
139
|
-
thread_safe (0.3.6)
|
140
|
-
tins (0.13.2)
|
141
|
-
tzinfo (1.2.5)
|
142
|
-
thread_safe (~> 0.1)
|
143
|
-
websocket-driver (0.7.0)
|
144
|
-
websocket-extensions (>= 0.1.0)
|
145
|
-
websocket-extensions (0.1.3)
|
146
|
-
|
147
|
-
PLATFORMS
|
148
|
-
ruby
|
149
|
-
|
150
|
-
DEPENDENCIES
|
151
|
-
appraisal
|
152
|
-
coveralls
|
153
|
-
mass_insert!
|
154
|
-
mysql2 (~> 0.4)
|
155
|
-
pg (~> 0.18)
|
156
|
-
rails (~> 5.0)
|
157
|
-
rake (~> 11.1)
|
158
|
-
simplecov
|
159
|
-
sqlite3 (~> 1.3)
|
160
|
-
|
161
|
-
BUNDLED WITH
|
162
|
-
1.16.2
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
shared_examples
|
4
|
-
|
5
|
-
describe 'Database Adapters' do
|
6
|
-
let(:attributes) do
|
7
|
-
{ name: 'Ruby' }
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
Kind.delete_all
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'with duplicated record' do
|
15
|
-
def setup
|
16
|
-
Kind.mass_insert([attributes])
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'does not raises error if is duplicated and has the duplication handler on' do
|
20
|
-
Kind.mass_insert([attributes], handle_duplication: true)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'raises error if is duplicated and does not have the duplication handler on' do
|
24
|
-
assert_raises ActiveRecord::RecordNotUnique do
|
25
|
-
Kind.mass_insert([attributes])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/test/database.yml.example
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
common: &common
|
2
|
-
encoding: utf8
|
3
|
-
database: mass_insert_test
|
4
|
-
|
5
|
-
mysql2:
|
6
|
-
<<: *common
|
7
|
-
adapter: mysql2
|
8
|
-
username: #your_mysql_username
|
9
|
-
password: #your_mysql_password
|
10
|
-
|
11
|
-
postgresql:
|
12
|
-
<<: *common
|
13
|
-
adapter: postgresql
|
14
|
-
username: #your_postgresql_username
|
15
|
-
password: #your_postgresql_password
|
16
|
-
|
17
|
-
sqlite3:
|
18
|
-
<<: *common
|
19
|
-
adapter: sqlite3
|
20
|
-
database: tmp/mass_insert_test.db
|
data/test/models/kind.rb
DELETED
data/test/models/post.rb
DELETED
data/test/models/user.rb
DELETED
data/test/schema.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
ActiveRecord::Schema.define do
|
2
|
-
create_table :users, force: true do |t|
|
3
|
-
t.string :name
|
4
|
-
t.boolean :active
|
5
|
-
t.integer :age
|
6
|
-
t.decimal :money, precision: 10, scale: 2
|
7
|
-
t.date :birth_date
|
8
|
-
t.timestamps null: false
|
9
|
-
end
|
10
|
-
|
11
|
-
create_table :kinds, force: true do |t|
|
12
|
-
t.string :name
|
13
|
-
t.index ['name'], name: 'index_kinds_on_name', unique: true, using: :btree
|
14
|
-
end
|
15
|
-
|
16
|
-
create_table :posts, force: true, id: false do |t|
|
17
|
-
t.integer :id, primary_key: true
|
18
|
-
t.string :name
|
19
|
-
end
|
20
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
ENV['DATABASE_ADAPTER'] = 'mysql2'
|
@@ -1 +0,0 @@
|
|
1
|
-
ENV['DATABASE_ADAPTER'] = 'postgresql'
|
@@ -1 +0,0 @@
|
|
1
|
-
ENV['DATABASE_ADAPTER'] = 'sqlite3'
|
@@ -1,90 +0,0 @@
|
|
1
|
-
def shared_examples
|
2
|
-
describe 'Database Adapters' do
|
3
|
-
let(:attributes) do
|
4
|
-
{
|
5
|
-
name: 'User Name',
|
6
|
-
active: true,
|
7
|
-
age: 25,
|
8
|
-
money: 20.50,
|
9
|
-
birth_date: Date.today,
|
10
|
-
created_at: DateTime.now,
|
11
|
-
updated_at: DateTime.now
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
after :each do
|
16
|
-
User.delete_all
|
17
|
-
Post.delete_all
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'Column types' do
|
21
|
-
def setup
|
22
|
-
User.mass_insert([attributes])
|
23
|
-
end
|
24
|
-
|
25
|
-
def user
|
26
|
-
@user ||= User.last
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'saves values correctly' do
|
30
|
-
assert_equal 'User Name', user.name
|
31
|
-
assert_equal true, user.active
|
32
|
-
assert_equal 25, user.age
|
33
|
-
assert_equal 20.50, user.money
|
34
|
-
assert_equal Date.today, user.birth_date
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'Bulk inseting' do
|
39
|
-
def array_of_values_with(size)
|
40
|
-
Array.new(size) { attributes }
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'saves 500 records correctly' do
|
44
|
-
values = array_of_values_with(500)
|
45
|
-
User.mass_insert(values)
|
46
|
-
assert_equal 500, User.count
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'saves 1000 records correctly' do
|
50
|
-
values = array_of_values_with(1000)
|
51
|
-
User.mass_insert(values)
|
52
|
-
assert_equal 1000, User.count
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'Primary key' do
|
57
|
-
describe 'when primary key is true' do
|
58
|
-
def setup
|
59
|
-
Post.mass_insert([
|
60
|
-
{ id: 10_000, name: 'Post' }
|
61
|
-
], primary_key: true)
|
62
|
-
end
|
63
|
-
|
64
|
-
def post
|
65
|
-
@post ||= Post.last
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'saves values correctly' do
|
69
|
-
assert_equal 10_000, post.id
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'when primary key is false' do
|
74
|
-
def setup
|
75
|
-
User.mass_insert([
|
76
|
-
attributes.merge(id: 10_000)
|
77
|
-
], primary_key: false)
|
78
|
-
end
|
79
|
-
|
80
|
-
def user
|
81
|
-
@user ||= User.last
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'saves values incorrectly' do
|
85
|
-
refute_equal 10_000, user.id
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|