activerecord-import 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +32 -0
  3. data/.rubocop.yml +49 -0
  4. data/.rubocop_todo.yml +36 -0
  5. data/.travis.yml +74 -0
  6. data/Brewfile +3 -0
  7. data/CHANGELOG.md +430 -0
  8. data/Gemfile +59 -0
  9. data/LICENSE +56 -0
  10. data/README.markdown +619 -0
  11. data/Rakefile +68 -0
  12. data/activerecord-import.gemspec +23 -0
  13. data/benchmarks/README +32 -0
  14. data/benchmarks/benchmark.rb +68 -0
  15. data/benchmarks/lib/base.rb +138 -0
  16. data/benchmarks/lib/cli_parser.rb +107 -0
  17. data/benchmarks/lib/float.rb +15 -0
  18. data/benchmarks/lib/mysql2_benchmark.rb +19 -0
  19. data/benchmarks/lib/output_to_csv.rb +19 -0
  20. data/benchmarks/lib/output_to_html.rb +64 -0
  21. data/benchmarks/models/test_innodb.rb +3 -0
  22. data/benchmarks/models/test_memory.rb +3 -0
  23. data/benchmarks/models/test_myisam.rb +3 -0
  24. data/benchmarks/schema/mysql_schema.rb +16 -0
  25. data/gemfiles/3.2.gemfile +2 -0
  26. data/gemfiles/4.0.gemfile +2 -0
  27. data/gemfiles/4.1.gemfile +2 -0
  28. data/gemfiles/4.2.gemfile +2 -0
  29. data/gemfiles/5.0.gemfile +2 -0
  30. data/gemfiles/5.1.gemfile +2 -0
  31. data/gemfiles/5.2.gemfile +2 -0
  32. data/gemfiles/6.0.gemfile +1 -0
  33. data/gemfiles/6.1.gemfile +1 -0
  34. data/lib/activerecord-import.rb +6 -0
  35. data/lib/activerecord-import/active_record/adapters/abstract_adapter.rb +9 -0
  36. data/lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb +6 -0
  37. data/lib/activerecord-import/active_record/adapters/jdbcpostgresql_adapter.rb +6 -0
  38. data/lib/activerecord-import/active_record/adapters/jdbcsqlite3_adapter.rb +6 -0
  39. data/lib/activerecord-import/active_record/adapters/mysql2_adapter.rb +6 -0
  40. data/lib/activerecord-import/active_record/adapters/postgresql_adapter.rb +6 -0
  41. data/lib/activerecord-import/active_record/adapters/seamless_database_pool_adapter.rb +7 -0
  42. data/lib/activerecord-import/active_record/adapters/sqlite3_adapter.rb +6 -0
  43. data/lib/activerecord-import/adapters/abstract_adapter.rb +66 -0
  44. data/lib/activerecord-import/adapters/em_mysql2_adapter.rb +5 -0
  45. data/lib/activerecord-import/adapters/mysql2_adapter.rb +5 -0
  46. data/lib/activerecord-import/adapters/mysql_adapter.rb +129 -0
  47. data/lib/activerecord-import/adapters/postgresql_adapter.rb +217 -0
  48. data/lib/activerecord-import/adapters/sqlite3_adapter.rb +180 -0
  49. data/lib/activerecord-import/base.rb +43 -0
  50. data/lib/activerecord-import/import.rb +1059 -0
  51. data/lib/activerecord-import/mysql2.rb +7 -0
  52. data/lib/activerecord-import/postgresql.rb +7 -0
  53. data/lib/activerecord-import/sqlite3.rb +7 -0
  54. data/lib/activerecord-import/synchronize.rb +66 -0
  55. data/lib/activerecord-import/value_sets_parser.rb +77 -0
  56. data/lib/activerecord-import/version.rb +5 -0
  57. data/test/adapters/jdbcmysql.rb +1 -0
  58. data/test/adapters/jdbcpostgresql.rb +1 -0
  59. data/test/adapters/jdbcsqlite3.rb +1 -0
  60. data/test/adapters/makara_postgis.rb +1 -0
  61. data/test/adapters/mysql2.rb +1 -0
  62. data/test/adapters/mysql2_makara.rb +1 -0
  63. data/test/adapters/mysql2spatial.rb +1 -0
  64. data/test/adapters/postgis.rb +1 -0
  65. data/test/adapters/postgresql.rb +1 -0
  66. data/test/adapters/postgresql_makara.rb +1 -0
  67. data/test/adapters/seamless_database_pool.rb +1 -0
  68. data/test/adapters/spatialite.rb +1 -0
  69. data/test/adapters/sqlite3.rb +1 -0
  70. data/test/database.yml.sample +52 -0
  71. data/test/import_test.rb +903 -0
  72. data/test/jdbcmysql/import_test.rb +5 -0
  73. data/test/jdbcpostgresql/import_test.rb +4 -0
  74. data/test/jdbcsqlite3/import_test.rb +4 -0
  75. data/test/makara_postgis/import_test.rb +8 -0
  76. data/test/models/account.rb +3 -0
  77. data/test/models/alarm.rb +2 -0
  78. data/test/models/bike_maker.rb +7 -0
  79. data/test/models/book.rb +9 -0
  80. data/test/models/car.rb +3 -0
  81. data/test/models/chapter.rb +4 -0
  82. data/test/models/dictionary.rb +4 -0
  83. data/test/models/discount.rb +3 -0
  84. data/test/models/end_note.rb +4 -0
  85. data/test/models/group.rb +3 -0
  86. data/test/models/promotion.rb +3 -0
  87. data/test/models/question.rb +3 -0
  88. data/test/models/rule.rb +3 -0
  89. data/test/models/tag.rb +4 -0
  90. data/test/models/topic.rb +23 -0
  91. data/test/models/user.rb +3 -0
  92. data/test/models/user_token.rb +4 -0
  93. data/test/models/vendor.rb +7 -0
  94. data/test/models/widget.rb +24 -0
  95. data/test/mysql2/import_test.rb +5 -0
  96. data/test/mysql2_makara/import_test.rb +6 -0
  97. data/test/mysqlspatial2/import_test.rb +6 -0
  98. data/test/postgis/import_test.rb +8 -0
  99. data/test/postgresql/import_test.rb +4 -0
  100. data/test/schema/generic_schema.rb +194 -0
  101. data/test/schema/jdbcpostgresql_schema.rb +1 -0
  102. data/test/schema/mysql2_schema.rb +19 -0
  103. data/test/schema/postgis_schema.rb +1 -0
  104. data/test/schema/postgresql_schema.rb +47 -0
  105. data/test/schema/sqlite3_schema.rb +13 -0
  106. data/test/schema/version.rb +10 -0
  107. data/test/sqlite3/import_test.rb +4 -0
  108. data/test/support/active_support/test_case_extensions.rb +75 -0
  109. data/test/support/assertions.rb +73 -0
  110. data/test/support/factories.rb +64 -0
  111. data/test/support/generate.rb +29 -0
  112. data/test/support/mysql/import_examples.rb +98 -0
  113. data/test/support/postgresql/import_examples.rb +563 -0
  114. data/test/support/shared_examples/on_duplicate_key_ignore.rb +43 -0
  115. data/test/support/shared_examples/on_duplicate_key_update.rb +368 -0
  116. data/test/support/shared_examples/recursive_import.rb +216 -0
  117. data/test/support/sqlite3/import_examples.rb +231 -0
  118. data/test/synchronize_test.rb +41 -0
  119. data/test/test_helper.rb +75 -0
  120. data/test/travis/database.yml +66 -0
  121. data/test/value_sets_bytes_parser_test.rb +104 -0
  122. data/test/value_sets_records_parser_test.rb +32 -0
  123. metadata +259 -0
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
+
3
+ require 'activerecord-import/value_sets_parser'
4
+
5
+ describe "ActiveRecord::Import::ValueSetsRecordsParser" do
6
+ context "#parse - computing insert value sets" do
7
+ let(:parser) { ActiveRecord::Import::ValueSetsRecordsParser }
8
+ let(:base_sql) { "INSERT INTO atable (a,b,c)" }
9
+ let(:values) { ["(1,2,3)", "(2,3,4)", "(3,4,5)"] }
10
+
11
+ context "when the max number of records is 1" do
12
+ it "should return 3 value sets when given 3 values sets" do
13
+ value_sets = parser.parse values, max_records: 1
14
+ assert_equal 3, value_sets.size
15
+ end
16
+ end
17
+
18
+ context "when the max number of records is 2" do
19
+ it "should return 2 value sets when given 3 values sets" do
20
+ value_sets = parser.parse values, max_records: 2
21
+ assert_equal 2, value_sets.size
22
+ end
23
+ end
24
+
25
+ context "when the max number of records is 3" do
26
+ it "should return 1 value sets when given 3 values sets" do
27
+ value_sets = parser.parse values, max_records: 3
28
+ assert_equal 1, value_sets.size
29
+ end
30
+ end
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,259 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-import
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Zach Dennis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A library for bulk inserting data using ActiveRecord.
42
+ email:
43
+ - zach.dennis@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rubocop.yml"
50
+ - ".rubocop_todo.yml"
51
+ - ".travis.yml"
52
+ - Brewfile
53
+ - CHANGELOG.md
54
+ - Gemfile
55
+ - LICENSE
56
+ - README.markdown
57
+ - Rakefile
58
+ - activerecord-import.gemspec
59
+ - benchmarks/README
60
+ - benchmarks/benchmark.rb
61
+ - benchmarks/lib/base.rb
62
+ - benchmarks/lib/cli_parser.rb
63
+ - benchmarks/lib/float.rb
64
+ - benchmarks/lib/mysql2_benchmark.rb
65
+ - benchmarks/lib/output_to_csv.rb
66
+ - benchmarks/lib/output_to_html.rb
67
+ - benchmarks/models/test_innodb.rb
68
+ - benchmarks/models/test_memory.rb
69
+ - benchmarks/models/test_myisam.rb
70
+ - benchmarks/schema/mysql_schema.rb
71
+ - gemfiles/3.2.gemfile
72
+ - gemfiles/4.0.gemfile
73
+ - gemfiles/4.1.gemfile
74
+ - gemfiles/4.2.gemfile
75
+ - gemfiles/5.0.gemfile
76
+ - gemfiles/5.1.gemfile
77
+ - gemfiles/5.2.gemfile
78
+ - gemfiles/6.0.gemfile
79
+ - gemfiles/6.1.gemfile
80
+ - lib/activerecord-import.rb
81
+ - lib/activerecord-import/active_record/adapters/abstract_adapter.rb
82
+ - lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb
83
+ - lib/activerecord-import/active_record/adapters/jdbcpostgresql_adapter.rb
84
+ - lib/activerecord-import/active_record/adapters/jdbcsqlite3_adapter.rb
85
+ - lib/activerecord-import/active_record/adapters/mysql2_adapter.rb
86
+ - lib/activerecord-import/active_record/adapters/postgresql_adapter.rb
87
+ - lib/activerecord-import/active_record/adapters/seamless_database_pool_adapter.rb
88
+ - lib/activerecord-import/active_record/adapters/sqlite3_adapter.rb
89
+ - lib/activerecord-import/adapters/abstract_adapter.rb
90
+ - lib/activerecord-import/adapters/em_mysql2_adapter.rb
91
+ - lib/activerecord-import/adapters/mysql2_adapter.rb
92
+ - lib/activerecord-import/adapters/mysql_adapter.rb
93
+ - lib/activerecord-import/adapters/postgresql_adapter.rb
94
+ - lib/activerecord-import/adapters/sqlite3_adapter.rb
95
+ - lib/activerecord-import/base.rb
96
+ - lib/activerecord-import/import.rb
97
+ - lib/activerecord-import/mysql2.rb
98
+ - lib/activerecord-import/postgresql.rb
99
+ - lib/activerecord-import/sqlite3.rb
100
+ - lib/activerecord-import/synchronize.rb
101
+ - lib/activerecord-import/value_sets_parser.rb
102
+ - lib/activerecord-import/version.rb
103
+ - test/adapters/jdbcmysql.rb
104
+ - test/adapters/jdbcpostgresql.rb
105
+ - test/adapters/jdbcsqlite3.rb
106
+ - test/adapters/makara_postgis.rb
107
+ - test/adapters/mysql2.rb
108
+ - test/adapters/mysql2_makara.rb
109
+ - test/adapters/mysql2spatial.rb
110
+ - test/adapters/postgis.rb
111
+ - test/adapters/postgresql.rb
112
+ - test/adapters/postgresql_makara.rb
113
+ - test/adapters/seamless_database_pool.rb
114
+ - test/adapters/spatialite.rb
115
+ - test/adapters/sqlite3.rb
116
+ - test/database.yml.sample
117
+ - test/import_test.rb
118
+ - test/jdbcmysql/import_test.rb
119
+ - test/jdbcpostgresql/import_test.rb
120
+ - test/jdbcsqlite3/import_test.rb
121
+ - test/makara_postgis/import_test.rb
122
+ - test/models/account.rb
123
+ - test/models/alarm.rb
124
+ - test/models/bike_maker.rb
125
+ - test/models/book.rb
126
+ - test/models/car.rb
127
+ - test/models/chapter.rb
128
+ - test/models/dictionary.rb
129
+ - test/models/discount.rb
130
+ - test/models/end_note.rb
131
+ - test/models/group.rb
132
+ - test/models/promotion.rb
133
+ - test/models/question.rb
134
+ - test/models/rule.rb
135
+ - test/models/tag.rb
136
+ - test/models/topic.rb
137
+ - test/models/user.rb
138
+ - test/models/user_token.rb
139
+ - test/models/vendor.rb
140
+ - test/models/widget.rb
141
+ - test/mysql2/import_test.rb
142
+ - test/mysql2_makara/import_test.rb
143
+ - test/mysqlspatial2/import_test.rb
144
+ - test/postgis/import_test.rb
145
+ - test/postgresql/import_test.rb
146
+ - test/schema/generic_schema.rb
147
+ - test/schema/jdbcpostgresql_schema.rb
148
+ - test/schema/mysql2_schema.rb
149
+ - test/schema/postgis_schema.rb
150
+ - test/schema/postgresql_schema.rb
151
+ - test/schema/sqlite3_schema.rb
152
+ - test/schema/version.rb
153
+ - test/sqlite3/import_test.rb
154
+ - test/support/active_support/test_case_extensions.rb
155
+ - test/support/assertions.rb
156
+ - test/support/factories.rb
157
+ - test/support/generate.rb
158
+ - test/support/mysql/import_examples.rb
159
+ - test/support/postgresql/import_examples.rb
160
+ - test/support/shared_examples/on_duplicate_key_ignore.rb
161
+ - test/support/shared_examples/on_duplicate_key_update.rb
162
+ - test/support/shared_examples/recursive_import.rb
163
+ - test/support/sqlite3/import_examples.rb
164
+ - test/synchronize_test.rb
165
+ - test/test_helper.rb
166
+ - test/travis/database.yml
167
+ - test/value_sets_bytes_parser_test.rb
168
+ - test/value_sets_records_parser_test.rb
169
+ homepage: http://github.com/zdennis/activerecord-import
170
+ licenses:
171
+ - Ruby
172
+ metadata: {}
173
+ post_install_message:
174
+ rdoc_options: []
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: 1.9.2
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ requirements: []
188
+ rubyforge_project:
189
+ rubygems_version: 2.7.7
190
+ signing_key:
191
+ specification_version: 4
192
+ summary: Bulk insert extension for ActiveRecord
193
+ test_files:
194
+ - test/adapters/jdbcmysql.rb
195
+ - test/adapters/jdbcpostgresql.rb
196
+ - test/adapters/jdbcsqlite3.rb
197
+ - test/adapters/makara_postgis.rb
198
+ - test/adapters/mysql2.rb
199
+ - test/adapters/mysql2_makara.rb
200
+ - test/adapters/mysql2spatial.rb
201
+ - test/adapters/postgis.rb
202
+ - test/adapters/postgresql.rb
203
+ - test/adapters/postgresql_makara.rb
204
+ - test/adapters/seamless_database_pool.rb
205
+ - test/adapters/spatialite.rb
206
+ - test/adapters/sqlite3.rb
207
+ - test/database.yml.sample
208
+ - test/import_test.rb
209
+ - test/jdbcmysql/import_test.rb
210
+ - test/jdbcpostgresql/import_test.rb
211
+ - test/jdbcsqlite3/import_test.rb
212
+ - test/makara_postgis/import_test.rb
213
+ - test/models/account.rb
214
+ - test/models/alarm.rb
215
+ - test/models/bike_maker.rb
216
+ - test/models/book.rb
217
+ - test/models/car.rb
218
+ - test/models/chapter.rb
219
+ - test/models/dictionary.rb
220
+ - test/models/discount.rb
221
+ - test/models/end_note.rb
222
+ - test/models/group.rb
223
+ - test/models/promotion.rb
224
+ - test/models/question.rb
225
+ - test/models/rule.rb
226
+ - test/models/tag.rb
227
+ - test/models/topic.rb
228
+ - test/models/user.rb
229
+ - test/models/user_token.rb
230
+ - test/models/vendor.rb
231
+ - test/models/widget.rb
232
+ - test/mysql2/import_test.rb
233
+ - test/mysql2_makara/import_test.rb
234
+ - test/mysqlspatial2/import_test.rb
235
+ - test/postgis/import_test.rb
236
+ - test/postgresql/import_test.rb
237
+ - test/schema/generic_schema.rb
238
+ - test/schema/jdbcpostgresql_schema.rb
239
+ - test/schema/mysql2_schema.rb
240
+ - test/schema/postgis_schema.rb
241
+ - test/schema/postgresql_schema.rb
242
+ - test/schema/sqlite3_schema.rb
243
+ - test/schema/version.rb
244
+ - test/sqlite3/import_test.rb
245
+ - test/support/active_support/test_case_extensions.rb
246
+ - test/support/assertions.rb
247
+ - test/support/factories.rb
248
+ - test/support/generate.rb
249
+ - test/support/mysql/import_examples.rb
250
+ - test/support/postgresql/import_examples.rb
251
+ - test/support/shared_examples/on_duplicate_key_ignore.rb
252
+ - test/support/shared_examples/on_duplicate_key_update.rb
253
+ - test/support/shared_examples/recursive_import.rb
254
+ - test/support/sqlite3/import_examples.rb
255
+ - test/synchronize_test.rb
256
+ - test/test_helper.rb
257
+ - test/travis/database.yml
258
+ - test/value_sets_bytes_parser_test.rb
259
+ - test/value_sets_records_parser_test.rb