mass_insert 0.2.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +10 -20
- data/.travis.yml +25 -5
- data/Appraisals +11 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +0 -5
- data/LICENSE.txt +17 -18
- data/README.md +54 -24
- data/Rakefile +3 -3
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_5.2.gemfile +7 -0
- data/gemfiles/rails_5.2.gemfile.lock +157 -0
- data/gemfiles/rails_6.0.gemfile +7 -0
- data/gemfiles/rails_6.0.gemfile.lock +173 -0
- data/gemfiles/rails_6.1.gemfile +7 -0
- data/gemfiles/rails_6.1.gemfile.lock +176 -0
- data/lib/mass_insert/adapters/abstract_adapter.rb +11 -5
- data/lib/mass_insert/base.rb +2 -1
- data/lib/mass_insert/builder.rb +1 -2
- data/lib/mass_insert/version.rb +1 -1
- data/mass_insert.gemspec +19 -12
- metadata +67 -51
- data/.rspec +0 -1
- 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/user.rb +0 -2
- data/test/schema.rb +0 -15
- 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 -57
- data/test/test_helper.rb +0 -36
@@ -0,0 +1,173 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
mass_insert (1.0.0)
|
5
|
+
activerecord (>= 5.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (6.0.3.6)
|
11
|
+
actionpack (= 6.0.3.6)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailbox (6.0.3.6)
|
15
|
+
actionpack (= 6.0.3.6)
|
16
|
+
activejob (= 6.0.3.6)
|
17
|
+
activerecord (= 6.0.3.6)
|
18
|
+
activestorage (= 6.0.3.6)
|
19
|
+
activesupport (= 6.0.3.6)
|
20
|
+
mail (>= 2.7.1)
|
21
|
+
actionmailer (6.0.3.6)
|
22
|
+
actionpack (= 6.0.3.6)
|
23
|
+
actionview (= 6.0.3.6)
|
24
|
+
activejob (= 6.0.3.6)
|
25
|
+
mail (~> 2.5, >= 2.5.4)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
actionpack (6.0.3.6)
|
28
|
+
actionview (= 6.0.3.6)
|
29
|
+
activesupport (= 6.0.3.6)
|
30
|
+
rack (~> 2.0, >= 2.0.8)
|
31
|
+
rack-test (>= 0.6.3)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
34
|
+
actiontext (6.0.3.6)
|
35
|
+
actionpack (= 6.0.3.6)
|
36
|
+
activerecord (= 6.0.3.6)
|
37
|
+
activestorage (= 6.0.3.6)
|
38
|
+
activesupport (= 6.0.3.6)
|
39
|
+
nokogiri (>= 1.8.5)
|
40
|
+
actionview (6.0.3.6)
|
41
|
+
activesupport (= 6.0.3.6)
|
42
|
+
builder (~> 3.1)
|
43
|
+
erubi (~> 1.4)
|
44
|
+
rails-dom-testing (~> 2.0)
|
45
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
46
|
+
activejob (6.0.3.6)
|
47
|
+
activesupport (= 6.0.3.6)
|
48
|
+
globalid (>= 0.3.6)
|
49
|
+
activemodel (6.0.3.6)
|
50
|
+
activesupport (= 6.0.3.6)
|
51
|
+
activerecord (6.0.3.6)
|
52
|
+
activemodel (= 6.0.3.6)
|
53
|
+
activesupport (= 6.0.3.6)
|
54
|
+
activestorage (6.0.3.6)
|
55
|
+
actionpack (= 6.0.3.6)
|
56
|
+
activejob (= 6.0.3.6)
|
57
|
+
activerecord (= 6.0.3.6)
|
58
|
+
marcel (~> 1.0.0)
|
59
|
+
activesupport (6.0.3.6)
|
60
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
61
|
+
i18n (>= 0.7, < 2)
|
62
|
+
minitest (~> 5.1)
|
63
|
+
tzinfo (~> 1.1)
|
64
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
65
|
+
appraisal (2.4.0)
|
66
|
+
bundler
|
67
|
+
rake
|
68
|
+
thor (>= 0.14.0)
|
69
|
+
builder (3.2.4)
|
70
|
+
concurrent-ruby (1.1.8)
|
71
|
+
coveralls (0.8.23)
|
72
|
+
json (>= 1.8, < 3)
|
73
|
+
simplecov (~> 0.16.1)
|
74
|
+
term-ansicolor (~> 1.3)
|
75
|
+
thor (>= 0.19.4, < 2.0)
|
76
|
+
tins (~> 1.6)
|
77
|
+
crass (1.0.6)
|
78
|
+
docile (1.3.5)
|
79
|
+
erubi (1.10.0)
|
80
|
+
globalid (0.4.2)
|
81
|
+
activesupport (>= 4.2.0)
|
82
|
+
i18n (1.8.10)
|
83
|
+
concurrent-ruby (~> 1.0)
|
84
|
+
json (2.5.1)
|
85
|
+
loofah (2.9.0)
|
86
|
+
crass (~> 1.0.2)
|
87
|
+
nokogiri (>= 1.5.9)
|
88
|
+
mail (2.7.1)
|
89
|
+
mini_mime (>= 0.1.1)
|
90
|
+
marcel (1.0.1)
|
91
|
+
method_source (1.0.0)
|
92
|
+
mini_mime (1.1.0)
|
93
|
+
mini_portile2 (2.5.0)
|
94
|
+
minitest (5.14.4)
|
95
|
+
mysql2 (0.5.3)
|
96
|
+
nio4r (2.5.7)
|
97
|
+
nokogiri (1.11.2)
|
98
|
+
mini_portile2 (~> 2.5.0)
|
99
|
+
racc (~> 1.4)
|
100
|
+
pg (1.2.3)
|
101
|
+
racc (1.5.2)
|
102
|
+
rack (2.2.3)
|
103
|
+
rack-test (1.1.0)
|
104
|
+
rack (>= 1.0, < 3)
|
105
|
+
rails (6.0.3.6)
|
106
|
+
actioncable (= 6.0.3.6)
|
107
|
+
actionmailbox (= 6.0.3.6)
|
108
|
+
actionmailer (= 6.0.3.6)
|
109
|
+
actionpack (= 6.0.3.6)
|
110
|
+
actiontext (= 6.0.3.6)
|
111
|
+
actionview (= 6.0.3.6)
|
112
|
+
activejob (= 6.0.3.6)
|
113
|
+
activemodel (= 6.0.3.6)
|
114
|
+
activerecord (= 6.0.3.6)
|
115
|
+
activestorage (= 6.0.3.6)
|
116
|
+
activesupport (= 6.0.3.6)
|
117
|
+
bundler (>= 1.3.0)
|
118
|
+
railties (= 6.0.3.6)
|
119
|
+
sprockets-rails (>= 2.0.0)
|
120
|
+
rails-dom-testing (2.0.3)
|
121
|
+
activesupport (>= 4.2.0)
|
122
|
+
nokogiri (>= 1.6)
|
123
|
+
rails-html-sanitizer (1.3.0)
|
124
|
+
loofah (~> 2.3)
|
125
|
+
railties (6.0.3.6)
|
126
|
+
actionpack (= 6.0.3.6)
|
127
|
+
activesupport (= 6.0.3.6)
|
128
|
+
method_source
|
129
|
+
rake (>= 0.8.7)
|
130
|
+
thor (>= 0.20.3, < 2.0)
|
131
|
+
rake (13.0.3)
|
132
|
+
simplecov (0.16.1)
|
133
|
+
docile (~> 1.1)
|
134
|
+
json (>= 1.8, < 3)
|
135
|
+
simplecov-html (~> 0.10.0)
|
136
|
+
simplecov-html (0.10.2)
|
137
|
+
sprockets (4.0.2)
|
138
|
+
concurrent-ruby (~> 1.0)
|
139
|
+
rack (> 1, < 3)
|
140
|
+
sprockets-rails (3.2.2)
|
141
|
+
actionpack (>= 4.0)
|
142
|
+
activesupport (>= 4.0)
|
143
|
+
sprockets (>= 3.0.0)
|
144
|
+
sqlite3 (1.4.2)
|
145
|
+
sync (0.5.0)
|
146
|
+
term-ansicolor (1.7.1)
|
147
|
+
tins (~> 1.0)
|
148
|
+
thor (1.1.0)
|
149
|
+
thread_safe (0.3.6)
|
150
|
+
tins (1.28.0)
|
151
|
+
sync
|
152
|
+
tzinfo (1.2.9)
|
153
|
+
thread_safe (~> 0.1)
|
154
|
+
websocket-driver (0.7.3)
|
155
|
+
websocket-extensions (>= 0.1.0)
|
156
|
+
websocket-extensions (0.1.5)
|
157
|
+
zeitwerk (2.4.2)
|
158
|
+
|
159
|
+
PLATFORMS
|
160
|
+
ruby
|
161
|
+
|
162
|
+
DEPENDENCIES
|
163
|
+
appraisal (~> 2.4)
|
164
|
+
coveralls (~> 0.8)
|
165
|
+
mass_insert!
|
166
|
+
mysql2 (~> 0.5)
|
167
|
+
pg (~> 1.2)
|
168
|
+
rails (~> 6.0.0)
|
169
|
+
rake (~> 13.0)
|
170
|
+
sqlite3 (~> 1.4)
|
171
|
+
|
172
|
+
BUNDLED WITH
|
173
|
+
2.1.4
|
@@ -0,0 +1,176 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
mass_insert (1.0.0)
|
5
|
+
activerecord (>= 5.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (6.1.3.1)
|
11
|
+
actionpack (= 6.1.3.1)
|
12
|
+
activesupport (= 6.1.3.1)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
actionmailbox (6.1.3.1)
|
16
|
+
actionpack (= 6.1.3.1)
|
17
|
+
activejob (= 6.1.3.1)
|
18
|
+
activerecord (= 6.1.3.1)
|
19
|
+
activestorage (= 6.1.3.1)
|
20
|
+
activesupport (= 6.1.3.1)
|
21
|
+
mail (>= 2.7.1)
|
22
|
+
actionmailer (6.1.3.1)
|
23
|
+
actionpack (= 6.1.3.1)
|
24
|
+
actionview (= 6.1.3.1)
|
25
|
+
activejob (= 6.1.3.1)
|
26
|
+
activesupport (= 6.1.3.1)
|
27
|
+
mail (~> 2.5, >= 2.5.4)
|
28
|
+
rails-dom-testing (~> 2.0)
|
29
|
+
actionpack (6.1.3.1)
|
30
|
+
actionview (= 6.1.3.1)
|
31
|
+
activesupport (= 6.1.3.1)
|
32
|
+
rack (~> 2.0, >= 2.0.9)
|
33
|
+
rack-test (>= 0.6.3)
|
34
|
+
rails-dom-testing (~> 2.0)
|
35
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
36
|
+
actiontext (6.1.3.1)
|
37
|
+
actionpack (= 6.1.3.1)
|
38
|
+
activerecord (= 6.1.3.1)
|
39
|
+
activestorage (= 6.1.3.1)
|
40
|
+
activesupport (= 6.1.3.1)
|
41
|
+
nokogiri (>= 1.8.5)
|
42
|
+
actionview (6.1.3.1)
|
43
|
+
activesupport (= 6.1.3.1)
|
44
|
+
builder (~> 3.1)
|
45
|
+
erubi (~> 1.4)
|
46
|
+
rails-dom-testing (~> 2.0)
|
47
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
48
|
+
activejob (6.1.3.1)
|
49
|
+
activesupport (= 6.1.3.1)
|
50
|
+
globalid (>= 0.3.6)
|
51
|
+
activemodel (6.1.3.1)
|
52
|
+
activesupport (= 6.1.3.1)
|
53
|
+
activerecord (6.1.3.1)
|
54
|
+
activemodel (= 6.1.3.1)
|
55
|
+
activesupport (= 6.1.3.1)
|
56
|
+
activestorage (6.1.3.1)
|
57
|
+
actionpack (= 6.1.3.1)
|
58
|
+
activejob (= 6.1.3.1)
|
59
|
+
activerecord (= 6.1.3.1)
|
60
|
+
activesupport (= 6.1.3.1)
|
61
|
+
marcel (~> 1.0.0)
|
62
|
+
mini_mime (~> 1.0.2)
|
63
|
+
activesupport (6.1.3.1)
|
64
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
65
|
+
i18n (>= 1.6, < 2)
|
66
|
+
minitest (>= 5.1)
|
67
|
+
tzinfo (~> 2.0)
|
68
|
+
zeitwerk (~> 2.3)
|
69
|
+
appraisal (2.4.0)
|
70
|
+
bundler
|
71
|
+
rake
|
72
|
+
thor (>= 0.14.0)
|
73
|
+
builder (3.2.4)
|
74
|
+
concurrent-ruby (1.1.8)
|
75
|
+
coveralls (0.8.23)
|
76
|
+
json (>= 1.8, < 3)
|
77
|
+
simplecov (~> 0.16.1)
|
78
|
+
term-ansicolor (~> 1.3)
|
79
|
+
thor (>= 0.19.4, < 2.0)
|
80
|
+
tins (~> 1.6)
|
81
|
+
crass (1.0.6)
|
82
|
+
docile (1.3.5)
|
83
|
+
erubi (1.10.0)
|
84
|
+
globalid (0.4.2)
|
85
|
+
activesupport (>= 4.2.0)
|
86
|
+
i18n (1.8.10)
|
87
|
+
concurrent-ruby (~> 1.0)
|
88
|
+
json (2.5.1)
|
89
|
+
loofah (2.9.0)
|
90
|
+
crass (~> 1.0.2)
|
91
|
+
nokogiri (>= 1.5.9)
|
92
|
+
mail (2.7.1)
|
93
|
+
mini_mime (>= 0.1.1)
|
94
|
+
marcel (1.0.1)
|
95
|
+
method_source (1.0.0)
|
96
|
+
mini_mime (1.0.3)
|
97
|
+
mini_portile2 (2.5.0)
|
98
|
+
minitest (5.14.4)
|
99
|
+
mysql2 (0.5.3)
|
100
|
+
nio4r (2.5.7)
|
101
|
+
nokogiri (1.11.2)
|
102
|
+
mini_portile2 (~> 2.5.0)
|
103
|
+
racc (~> 1.4)
|
104
|
+
pg (1.2.3)
|
105
|
+
racc (1.5.2)
|
106
|
+
rack (2.2.3)
|
107
|
+
rack-test (1.1.0)
|
108
|
+
rack (>= 1.0, < 3)
|
109
|
+
rails (6.1.3.1)
|
110
|
+
actioncable (= 6.1.3.1)
|
111
|
+
actionmailbox (= 6.1.3.1)
|
112
|
+
actionmailer (= 6.1.3.1)
|
113
|
+
actionpack (= 6.1.3.1)
|
114
|
+
actiontext (= 6.1.3.1)
|
115
|
+
actionview (= 6.1.3.1)
|
116
|
+
activejob (= 6.1.3.1)
|
117
|
+
activemodel (= 6.1.3.1)
|
118
|
+
activerecord (= 6.1.3.1)
|
119
|
+
activestorage (= 6.1.3.1)
|
120
|
+
activesupport (= 6.1.3.1)
|
121
|
+
bundler (>= 1.15.0)
|
122
|
+
railties (= 6.1.3.1)
|
123
|
+
sprockets-rails (>= 2.0.0)
|
124
|
+
rails-dom-testing (2.0.3)
|
125
|
+
activesupport (>= 4.2.0)
|
126
|
+
nokogiri (>= 1.6)
|
127
|
+
rails-html-sanitizer (1.3.0)
|
128
|
+
loofah (~> 2.3)
|
129
|
+
railties (6.1.3.1)
|
130
|
+
actionpack (= 6.1.3.1)
|
131
|
+
activesupport (= 6.1.3.1)
|
132
|
+
method_source
|
133
|
+
rake (>= 0.8.7)
|
134
|
+
thor (~> 1.0)
|
135
|
+
rake (13.0.3)
|
136
|
+
simplecov (0.16.1)
|
137
|
+
docile (~> 1.1)
|
138
|
+
json (>= 1.8, < 3)
|
139
|
+
simplecov-html (~> 0.10.0)
|
140
|
+
simplecov-html (0.10.2)
|
141
|
+
sprockets (4.0.2)
|
142
|
+
concurrent-ruby (~> 1.0)
|
143
|
+
rack (> 1, < 3)
|
144
|
+
sprockets-rails (3.2.2)
|
145
|
+
actionpack (>= 4.0)
|
146
|
+
activesupport (>= 4.0)
|
147
|
+
sprockets (>= 3.0.0)
|
148
|
+
sqlite3 (1.4.2)
|
149
|
+
sync (0.5.0)
|
150
|
+
term-ansicolor (1.7.1)
|
151
|
+
tins (~> 1.0)
|
152
|
+
thor (1.1.0)
|
153
|
+
tins (1.28.0)
|
154
|
+
sync
|
155
|
+
tzinfo (2.0.4)
|
156
|
+
concurrent-ruby (~> 1.0)
|
157
|
+
websocket-driver (0.7.3)
|
158
|
+
websocket-extensions (>= 0.1.0)
|
159
|
+
websocket-extensions (0.1.5)
|
160
|
+
zeitwerk (2.4.2)
|
161
|
+
|
162
|
+
PLATFORMS
|
163
|
+
ruby
|
164
|
+
|
165
|
+
DEPENDENCIES
|
166
|
+
appraisal (~> 2.4)
|
167
|
+
coveralls (~> 0.8)
|
168
|
+
mass_insert!
|
169
|
+
mysql2 (~> 0.5)
|
170
|
+
pg (~> 1.2)
|
171
|
+
rails (~> 6.1.0)
|
172
|
+
rake (~> 13.0)
|
173
|
+
sqlite3 (~> 1.4)
|
174
|
+
|
175
|
+
BUNDLED WITH
|
176
|
+
2.1.4
|
@@ -3,10 +3,10 @@ module MassInsert
|
|
3
3
|
class AbstractAdapter < SimpleDelegator
|
4
4
|
attr_accessor :values, :options
|
5
5
|
|
6
|
-
def initialize(
|
6
|
+
def initialize(values, options)
|
7
|
+
super(options.fetch(:class_name))
|
7
8
|
@values = values
|
8
9
|
@options = options
|
9
|
-
super(class_name)
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_sql
|
@@ -17,8 +17,8 @@ module MassInsert
|
|
17
17
|
|
18
18
|
def columns
|
19
19
|
@columns ||= begin
|
20
|
-
columns = column_names
|
21
|
-
columns.delete(primary_key)
|
20
|
+
columns = column_names.dup
|
21
|
+
columns.delete(primary_key) unless options[:primary_key]
|
22
22
|
columns.map(&:to_sym)
|
23
23
|
end
|
24
24
|
end
|
@@ -44,11 +44,17 @@ module MassInsert
|
|
44
44
|
def array_of_attributes_sql
|
45
45
|
values.map do |attrs|
|
46
46
|
columns.map do |name|
|
47
|
-
value = attrs
|
47
|
+
value = column_value(attrs, name)
|
48
48
|
connection.quote(value)
|
49
49
|
end.join(',')
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
def column_value(attrs, column)
|
54
|
+
attrs.fetch(column.to_sym) do
|
55
|
+
attrs.fetch(column.to_s, nil)
|
56
|
+
end
|
57
|
+
end
|
52
58
|
end
|
53
59
|
end
|
54
60
|
end
|
data/lib/mass_insert/base.rb
CHANGED
data/lib/mass_insert/builder.rb
CHANGED
data/lib/mass_insert/version.rb
CHANGED
data/mass_insert.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'mass_insert/version'
|
5
4
|
|
@@ -13,17 +12,25 @@ Gem::Specification.new do |spec|
|
|
13
12
|
spec.homepage = 'https://github.com/alejandrodevs/mass_insert'
|
14
13
|
spec.license = 'MIT'
|
15
14
|
|
16
|
-
spec.
|
17
|
-
spec.
|
18
|
-
spec.
|
19
|
-
spec.require_paths = ['lib']
|
15
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
16
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
17
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/master/LICENSE.txt"
|
20
18
|
|
21
|
-
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = 'exe'
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ['lib']
|
22
27
|
|
23
|
-
spec.
|
28
|
+
spec.add_development_dependency 'pg', '~> 1.2'
|
29
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
30
|
+
spec.add_development_dependency 'mysql2', '~> 0.5'
|
31
|
+
spec.add_development_dependency 'sqlite3', '~> 1.4'
|
32
|
+
spec.add_development_dependency 'appraisal', '~> 2.4'
|
33
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
24
34
|
|
25
|
-
spec.
|
26
|
-
spec.add_development_dependency 'rake', '~> 11.1'
|
27
|
-
spec.add_development_dependency 'mysql2', '~> 0.4'
|
28
|
-
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
35
|
+
spec.add_dependency 'activerecord', '>= 5.2'
|
29
36
|
end
|