activerecord-import 0.25.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yaml +151 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +74 -8
- data/.rubocop_todo.yml +10 -16
- data/Brewfile +3 -1
- data/CHANGELOG.md +232 -2
- data/Dockerfile +23 -0
- data/Gemfile +26 -14
- data/LICENSE +21 -56
- data/README.markdown +612 -21
- data/Rakefile +4 -1
- data/activerecord-import.gemspec +6 -5
- data/benchmarks/benchmark.rb +10 -4
- data/benchmarks/lib/base.rb +4 -2
- data/benchmarks/lib/cli_parser.rb +4 -2
- data/benchmarks/lib/float.rb +2 -0
- data/benchmarks/lib/mysql2_benchmark.rb +2 -0
- data/benchmarks/lib/output_to_csv.rb +2 -0
- data/benchmarks/lib/output_to_html.rb +4 -2
- data/benchmarks/models/test_innodb.rb +2 -0
- data/benchmarks/models/test_memory.rb +2 -0
- data/benchmarks/models/test_myisam.rb +2 -0
- data/benchmarks/schema/{mysql_schema.rb → mysql2_schema.rb} +2 -0
- data/docker-compose.yml +34 -0
- data/gemfiles/4.2.gemfile +2 -0
- data/gemfiles/5.0.gemfile +2 -0
- data/gemfiles/5.1.gemfile +2 -0
- data/gemfiles/5.2.gemfile +2 -0
- data/gemfiles/6.0.gemfile +4 -0
- data/gemfiles/6.1.gemfile +4 -0
- data/gemfiles/7.0.gemfile +4 -0
- data/gemfiles/7.1.gemfile +3 -0
- data/lib/activerecord-import/active_record/adapters/abstract_adapter.rb +2 -0
- data/lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb +6 -4
- data/lib/activerecord-import/active_record/adapters/jdbcpostgresql_adapter.rb +2 -0
- data/lib/activerecord-import/active_record/adapters/jdbcsqlite3_adapter.rb +2 -0
- data/lib/activerecord-import/active_record/adapters/mysql2_adapter.rb +2 -0
- data/lib/activerecord-import/active_record/adapters/postgresql_adapter.rb +2 -0
- data/lib/activerecord-import/active_record/adapters/seamless_database_pool_adapter.rb +2 -0
- data/lib/activerecord-import/active_record/adapters/sqlite3_adapter.rb +2 -0
- data/lib/activerecord-import/active_record/adapters/trilogy_adapter.rb +8 -0
- data/lib/activerecord-import/adapters/abstract_adapter.rb +15 -6
- data/lib/activerecord-import/adapters/em_mysql2_adapter.rb +2 -0
- data/lib/activerecord-import/adapters/mysql2_adapter.rb +2 -0
- data/lib/activerecord-import/adapters/mysql_adapter.rb +34 -29
- data/lib/activerecord-import/adapters/postgresql_adapter.rb +74 -55
- data/lib/activerecord-import/adapters/sqlite3_adapter.rb +138 -13
- data/lib/activerecord-import/adapters/trilogy_adapter.rb +7 -0
- data/lib/activerecord-import/base.rb +11 -2
- data/lib/activerecord-import/import.rb +290 -114
- data/lib/activerecord-import/mysql2.rb +2 -0
- data/lib/activerecord-import/postgresql.rb +2 -0
- data/lib/activerecord-import/sqlite3.rb +2 -0
- data/lib/activerecord-import/synchronize.rb +4 -2
- data/lib/activerecord-import/value_sets_parser.rb +5 -0
- data/lib/activerecord-import/version.rb +3 -1
- data/lib/activerecord-import.rb +2 -1
- data/test/adapters/jdbcmysql.rb +2 -0
- data/test/adapters/jdbcpostgresql.rb +2 -0
- data/test/adapters/jdbcsqlite3.rb +2 -0
- data/test/adapters/makara_postgis.rb +2 -0
- data/test/adapters/mysql2.rb +2 -0
- data/test/adapters/mysql2_makara.rb +2 -0
- data/test/adapters/mysql2spatial.rb +2 -0
- data/test/adapters/postgis.rb +2 -0
- data/test/adapters/postgresql.rb +2 -0
- data/test/adapters/postgresql_makara.rb +2 -0
- data/test/adapters/seamless_database_pool.rb +2 -0
- data/test/adapters/spatialite.rb +2 -0
- data/test/adapters/sqlite3.rb +2 -0
- data/test/adapters/trilogy.rb +9 -0
- data/test/database.yml.sample +7 -0
- data/test/{travis → github}/database.yml +7 -1
- data/test/import_test.rb +151 -8
- data/test/jdbcmysql/import_test.rb +5 -3
- data/test/jdbcpostgresql/import_test.rb +4 -2
- data/test/jdbcsqlite3/import_test.rb +4 -2
- data/test/makara_postgis/import_test.rb +4 -2
- data/test/models/account.rb +2 -0
- data/test/models/alarm.rb +2 -0
- data/test/models/animal.rb +8 -0
- data/test/models/author.rb +7 -0
- data/test/models/bike_maker.rb +3 -0
- data/test/models/book.rb +7 -2
- data/test/models/car.rb +2 -0
- data/test/models/card.rb +5 -0
- data/test/models/chapter.rb +2 -0
- data/test/models/composite_book.rb +19 -0
- data/test/models/composite_chapter.rb +9 -0
- data/test/models/customer.rb +18 -0
- data/test/models/deck.rb +8 -0
- data/test/models/dictionary.rb +2 -0
- data/test/models/discount.rb +2 -0
- data/test/models/end_note.rb +2 -0
- data/test/models/group.rb +2 -0
- data/test/models/order.rb +17 -0
- data/test/models/playing_card.rb +4 -0
- data/test/models/promotion.rb +2 -0
- data/test/models/question.rb +2 -0
- data/test/models/rule.rb +2 -0
- data/test/models/tag.rb +9 -1
- data/test/models/tag_alias.rb +11 -0
- data/test/models/topic.rb +7 -0
- data/test/models/user.rb +2 -0
- data/test/models/user_token.rb +3 -0
- data/test/models/vendor.rb +2 -0
- data/test/models/widget.rb +2 -0
- data/test/mysql2/import_test.rb +5 -3
- data/test/mysql2_makara/import_test.rb +5 -3
- data/test/mysqlspatial2/import_test.rb +5 -3
- data/test/postgis/import_test.rb +4 -2
- data/test/postgresql/import_test.rb +4 -2
- data/test/schema/generic_schema.rb +37 -1
- data/test/schema/jdbcpostgresql_schema.rb +3 -1
- data/test/schema/mysql2_schema.rb +2 -0
- data/test/schema/postgis_schema.rb +3 -1
- data/test/schema/postgresql_schema.rb +49 -0
- data/test/schema/sqlite3_schema.rb +15 -0
- data/test/schema/version.rb +2 -0
- data/test/sqlite3/import_test.rb +4 -2
- data/test/support/active_support/test_case_extensions.rb +2 -0
- data/test/support/assertions.rb +2 -0
- data/test/support/factories.rb +10 -8
- data/test/support/generate.rb +10 -8
- data/test/support/mysql/import_examples.rb +2 -1
- data/test/support/postgresql/import_examples.rb +152 -3
- data/test/support/shared_examples/on_duplicate_key_ignore.rb +2 -0
- data/test/support/shared_examples/on_duplicate_key_update.rb +122 -9
- data/test/support/shared_examples/recursive_import.rb +128 -2
- data/test/support/sqlite3/import_examples.rb +191 -26
- data/test/synchronize_test.rb +2 -0
- data/test/test_helper.rb +34 -7
- data/test/trilogy/import_test.rb +7 -0
- data/test/value_sets_bytes_parser_test.rb +3 -1
- data/test/value_sets_records_parser_test.rb +3 -1
- metadata +46 -16
- data/.travis.yml +0 -71
- data/gemfiles/3.2.gemfile +0 -2
- data/gemfiles/4.0.gemfile +0 -2
- data/gemfiles/4.1.gemfile +0 -2
@@ -1,23 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
def should_support_sqlite3_import_functionality
|
3
|
-
|
4
|
+
if ActiveRecord::Base.connection.supports_on_duplicate_key_update?
|
5
|
+
should_support_sqlite_upsert_functionality
|
6
|
+
end
|
4
7
|
|
5
8
|
describe "#supports_imports?" do
|
6
|
-
|
7
|
-
|
8
|
-
version = ActiveRecord::ConnectionAdapters::SQLite3Adapter::Version.new("3.7.11")
|
9
|
-
assert ActiveRecord::Base.supports_import?(version)
|
10
|
-
|
11
|
-
version = ActiveRecord::ConnectionAdapters::SQLite3Adapter::Version.new("3.7.12")
|
12
|
-
assert ActiveRecord::Base.supports_import?(version)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "and SQLite less than 3.7.11" do
|
17
|
-
it "doesn't support import" do
|
18
|
-
version = ActiveRecord::ConnectionAdapters::SQLite3Adapter::Version.new("3.7.10")
|
19
|
-
assert !ActiveRecord::Base.supports_import?(version)
|
20
|
-
end
|
9
|
+
it "should support import" do
|
10
|
+
assert ActiveRecord::Base.supports_import?
|
21
11
|
end
|
22
12
|
end
|
23
13
|
|
@@ -49,18 +39,193 @@ def should_support_sqlite3_import_functionality
|
|
49
39
|
assert_equal 2500, Topic.count, "Failed to insert all records. Make sure you have a supported version of SQLite3 (3.7.11 or higher) installed"
|
50
40
|
end
|
51
41
|
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def should_support_sqlite_upsert_functionality
|
46
|
+
should_support_basic_on_duplicate_key_update
|
47
|
+
should_support_on_duplicate_key_ignore
|
48
|
+
|
49
|
+
describe "#import" do
|
50
|
+
extend ActiveSupport::TestCase::ImportAssertions
|
51
|
+
|
52
|
+
macro(:perform_import) { raise "supply your own #perform_import in a context below" }
|
53
|
+
macro(:updated_topic) { Topic.find(@topic.id) }
|
54
|
+
|
55
|
+
context "with :on_duplicate_key_ignore and validation checks turned off" do
|
56
|
+
let(:columns) { %w( id title author_name author_email_address parent_id ) }
|
57
|
+
let(:values) { [[99, "Book", "John Doe", "john@doe.com", 17]] }
|
58
|
+
let(:updated_values) { [[99, "Book - 2nd Edition", "Author Should Not Change", "johndoe@example.com", 57]] }
|
59
|
+
|
60
|
+
setup do
|
61
|
+
Topic.import columns, values, validate: false
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should not update any records" do
|
65
|
+
result = Topic.import columns, updated_values, on_duplicate_key_ignore: true, validate: false
|
66
|
+
assert_equal [], result.ids
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with :on_duplicate_key_update and validation checks turned off" do
|
71
|
+
asssertion_group(:should_support_on_duplicate_key_update) do
|
72
|
+
should_not_update_fields_not_mentioned
|
73
|
+
should_update_foreign_keys
|
74
|
+
should_not_update_created_at_on_timestamp_columns
|
75
|
+
should_update_updated_at_on_timestamp_columns
|
76
|
+
end
|
77
|
+
|
78
|
+
context "using a hash" do
|
79
|
+
context "with :columns a hash" do
|
80
|
+
let(:columns) { %w( id title author_name author_email_address parent_id ) }
|
81
|
+
let(:values) { [[99, "Book", "John Doe", "john@doe.com", 17]] }
|
82
|
+
let(:updated_values) { [[99, "Book - 2nd Edition", "Author Should Not Change", "johndoe@example.com", 57]] }
|
83
|
+
|
84
|
+
macro(:perform_import) do |*opts|
|
85
|
+
Topic.import columns, updated_values, opts.extract_options!.merge(on_duplicate_key_update: { conflict_target: :id, columns: update_columns }, validate: false)
|
86
|
+
end
|
87
|
+
|
88
|
+
setup do
|
89
|
+
Topic.import columns, values, validate: false
|
90
|
+
@topic = Topic.find 99
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should not modify the passed in :on_duplicate_key_update columns array" do
|
94
|
+
assert_nothing_raised do
|
95
|
+
columns = %w(title author_name).freeze
|
96
|
+
Topic.import columns, [%w(foo, bar)], on_duplicate_key_update: { columns: columns }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "using string hash map" do
|
101
|
+
let(:update_columns) { { "title" => "title", "author_email_address" => "author_email_address", "parent_id" => "parent_id" } }
|
102
|
+
should_support_on_duplicate_key_update
|
103
|
+
should_update_fields_mentioned
|
104
|
+
end
|
105
|
+
|
106
|
+
context "using string hash map, but specifying column mismatches" do
|
107
|
+
let(:update_columns) { { "title" => "author_email_address", "author_email_address" => "title", "parent_id" => "parent_id" } }
|
108
|
+
should_support_on_duplicate_key_update
|
109
|
+
should_update_fields_mentioned_with_hash_mappings
|
110
|
+
end
|
111
|
+
|
112
|
+
context "using symbol hash map" do
|
113
|
+
let(:update_columns) { { title: :title, author_email_address: :author_email_address, parent_id: :parent_id } }
|
114
|
+
should_support_on_duplicate_key_update
|
115
|
+
should_update_fields_mentioned
|
116
|
+
end
|
117
|
+
|
118
|
+
context "using symbol hash map, but specifying column mismatches" do
|
119
|
+
let(:update_columns) { { title: :author_email_address, author_email_address: :title, parent_id: :parent_id } }
|
120
|
+
should_support_on_duplicate_key_update
|
121
|
+
should_update_fields_mentioned_with_hash_mappings
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'with :index_predicate' do
|
126
|
+
let(:columns) { %w( id device_id alarm_type status metadata ) }
|
127
|
+
let(:values) { [[99, 17, 1, 1, 'foo']] }
|
128
|
+
let(:updated_values) { [[99, 17, 1, 2, 'bar']] }
|
129
|
+
|
130
|
+
macro(:perform_import) do |*opts|
|
131
|
+
Alarm.import columns, updated_values, opts.extract_options!.merge(on_duplicate_key_update: { conflict_target: [:device_id, :alarm_type], index_predicate: 'status <> 0', columns: [:status] }, validate: false)
|
132
|
+
end
|
133
|
+
|
134
|
+
macro(:updated_alarm) { Alarm.find(@alarm.id) }
|
135
|
+
|
136
|
+
setup do
|
137
|
+
Alarm.import columns, values, validate: false
|
138
|
+
@alarm = Alarm.find 99
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'supports on duplicate key update for partial indexes' do
|
142
|
+
it 'should not update created_at timestamp columns' do
|
143
|
+
Timecop.freeze Chronic.parse("5 minutes from now") do
|
144
|
+
perform_import
|
145
|
+
assert_in_delta @alarm.created_at.to_i, updated_alarm.created_at.to_i, 1
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should update updated_at timestamp columns' do
|
150
|
+
time = Chronic.parse("5 minutes from now")
|
151
|
+
Timecop.freeze time do
|
152
|
+
perform_import
|
153
|
+
assert_in_delta time.to_i, updated_alarm.updated_at.to_i, 1
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'should not update fields not mentioned' do
|
158
|
+
perform_import
|
159
|
+
assert_equal 'foo', updated_alarm.metadata
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should update fields mentioned with hash mappings' do
|
163
|
+
perform_import
|
164
|
+
assert_equal 2, updated_alarm.status
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context 'with :condition' do
|
170
|
+
let(:columns) { %w( id device_id alarm_type status metadata) }
|
171
|
+
let(:values) { [[99, 17, 1, 1, 'foo']] }
|
172
|
+
let(:updated_values) { [[99, 17, 1, 1, 'bar']] }
|
173
|
+
|
174
|
+
macro(:perform_import) do |*opts|
|
175
|
+
Alarm.import(
|
176
|
+
columns,
|
177
|
+
updated_values,
|
178
|
+
opts.extract_options!.merge(
|
179
|
+
on_duplicate_key_update: {
|
180
|
+
conflict_target: [:id],
|
181
|
+
condition: "alarms.metadata NOT LIKE '%foo%'",
|
182
|
+
columns: [:metadata]
|
183
|
+
},
|
184
|
+
validate: false
|
185
|
+
)
|
186
|
+
)
|
187
|
+
end
|
188
|
+
|
189
|
+
macro(:updated_alarm) { Alarm.find(@alarm.id) }
|
190
|
+
|
191
|
+
setup do
|
192
|
+
Alarm.import columns, values, validate: false
|
193
|
+
@alarm = Alarm.find 99
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'should not update fields not matched' do
|
197
|
+
perform_import
|
198
|
+
assert_equal 'foo', updated_alarm.metadata
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context "with no :conflict_target" do
|
203
|
+
context "with no primary key" do
|
204
|
+
it "raises ArgumentError" do
|
205
|
+
error = assert_raises ArgumentError do
|
206
|
+
Rule.import Build(3, :rules), on_duplicate_key_update: [:condition_text], validate: false
|
207
|
+
end
|
208
|
+
assert_match(/Expected :conflict_target to be specified/, error.message)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
context "with no :columns" do
|
214
|
+
let(:columns) { %w( id title author_name author_email_address ) }
|
215
|
+
let(:values) { [[100, "Book", "John Doe", "john@doe.com"]] }
|
216
|
+
let(:updated_values) { [[100, "Title Should Not Change", "Author Should Not Change", "john@nogo.com"]] }
|
52
217
|
|
53
|
-
|
54
|
-
|
218
|
+
macro(:perform_import) do |*opts|
|
219
|
+
Topic.import columns, updated_values, opts.extract_options!.merge(on_duplicate_key_update: { conflict_target: :id }, validate: false)
|
220
|
+
end
|
55
221
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
ActiveRecord::Base.connection.stubs(:logger).returns(logger)
|
222
|
+
setup do
|
223
|
+
Topic.import columns, values, validate: false
|
224
|
+
@topic = Topic.find 100
|
225
|
+
end
|
61
226
|
|
62
|
-
|
63
|
-
|
227
|
+
should_update_updated_at_on_timestamp_columns
|
228
|
+
end
|
64
229
|
end
|
65
230
|
end
|
66
231
|
end
|
data/test/synchronize_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pathname'
|
4
|
+
require 'rake'
|
2
5
|
test_dir = Pathname.new File.dirname(__FILE__)
|
3
6
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
7
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
@@ -21,7 +24,7 @@ if ActiveSupport::VERSION::STRING < "4.0"
|
|
21
24
|
require 'mocha/test_unit'
|
22
25
|
else
|
23
26
|
require 'active_support/testing/autorun'
|
24
|
-
require "mocha/
|
27
|
+
require "mocha/minitest"
|
25
28
|
end
|
26
29
|
|
27
30
|
require 'timecop'
|
@@ -30,7 +33,9 @@ require 'chronic'
|
|
30
33
|
begin
|
31
34
|
require 'composite_primary_keys'
|
32
35
|
rescue LoadError
|
33
|
-
ENV[
|
36
|
+
if ENV['AR_VERSION'].to_f <= 7.1
|
37
|
+
ENV['SKIP_COMPOSITE_PK'] = 'true'
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
41
|
# Support MySQL 5.7
|
@@ -48,8 +53,30 @@ adapter = ENV["ARE_DB"] || "sqlite3"
|
|
48
53
|
FileUtils.mkdir_p 'log'
|
49
54
|
ActiveRecord::Base.logger = Logger.new("log/test.log")
|
50
55
|
ActiveRecord::Base.logger.level = Logger::DEBUG
|
51
|
-
|
52
|
-
ActiveRecord
|
56
|
+
|
57
|
+
if ActiveRecord.respond_to?(:use_yaml_unsafe_load)
|
58
|
+
ActiveRecord.use_yaml_unsafe_load = true
|
59
|
+
elsif ActiveRecord::Base.respond_to?(:use_yaml_unsafe_load)
|
60
|
+
ActiveRecord::Base.use_yaml_unsafe_load = true
|
61
|
+
end
|
62
|
+
|
63
|
+
if ENV['AR_VERSION'].to_f >= 6.0
|
64
|
+
yaml_config = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.2.1')
|
65
|
+
YAML.safe_load_file(test_dir.join("database.yml"), aliases: true)[adapter]
|
66
|
+
else
|
67
|
+
YAML.load_file(test_dir.join("database.yml"))[adapter]
|
68
|
+
end
|
69
|
+
config = ActiveRecord::DatabaseConfigurations::HashConfig.new("test", adapter, yaml_config)
|
70
|
+
ActiveRecord::Base.configurations.configurations << config
|
71
|
+
else
|
72
|
+
ActiveRecord::Base.configurations["test"] = YAML.load_file(test_dir.join("database.yml"))[adapter]
|
73
|
+
end
|
74
|
+
|
75
|
+
if ActiveRecord.respond_to?(:default_timezone)
|
76
|
+
ActiveRecord.default_timezone = :utc
|
77
|
+
else
|
78
|
+
ActiveRecord::Base.default_timezone = :utc
|
79
|
+
end
|
53
80
|
|
54
81
|
require "activerecord-import"
|
55
82
|
ActiveRecord::Base.establish_connection :test
|
@@ -58,8 +85,8 @@ ActiveSupport::Notifications.subscribe(/active_record.sql/) do |_, _, _, _, hsh|
|
|
58
85
|
ActiveRecord::Base.logger.info hsh[:sql]
|
59
86
|
end
|
60
87
|
|
61
|
-
require "
|
62
|
-
Dir[File.dirname(__FILE__)
|
88
|
+
require "factory_bot"
|
89
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |file| require file }
|
63
90
|
|
64
91
|
# Load base/generic schema
|
65
92
|
require test_dir.join("schema/version")
|
@@ -67,7 +94,7 @@ require test_dir.join("schema/generic_schema")
|
|
67
94
|
adapter_schema = test_dir.join("schema/#{adapter}_schema.rb")
|
68
95
|
require adapter_schema if File.exist?(adapter_schema)
|
69
96
|
|
70
|
-
Dir[File.dirname(__FILE__)
|
97
|
+
Dir["#{File.dirname(__FILE__)}/models/*.rb"].sort.each { |file| require file }
|
71
98
|
|
72
99
|
# Prevent this deprecation warning from breaking the tests.
|
73
100
|
Rake::FileList.send(:remove_method, :import)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
4
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
5
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
6
|
+
|
7
|
+
should_support_mysql_import_functionality
|
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:
|
4
|
+
version: 1.7.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:
|
11
|
+
date: 2024-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,12 +45,13 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/test.yaml"
|
48
49
|
- ".gitignore"
|
49
50
|
- ".rubocop.yml"
|
50
51
|
- ".rubocop_todo.yml"
|
51
|
-
- ".travis.yml"
|
52
52
|
- Brewfile
|
53
53
|
- CHANGELOG.md
|
54
|
+
- Dockerfile
|
54
55
|
- Gemfile
|
55
56
|
- LICENSE
|
56
57
|
- README.markdown
|
@@ -67,14 +68,16 @@ files:
|
|
67
68
|
- benchmarks/models/test_innodb.rb
|
68
69
|
- benchmarks/models/test_memory.rb
|
69
70
|
- benchmarks/models/test_myisam.rb
|
70
|
-
- benchmarks/schema/
|
71
|
-
-
|
72
|
-
- gemfiles/4.0.gemfile
|
73
|
-
- gemfiles/4.1.gemfile
|
71
|
+
- benchmarks/schema/mysql2_schema.rb
|
72
|
+
- docker-compose.yml
|
74
73
|
- gemfiles/4.2.gemfile
|
75
74
|
- gemfiles/5.0.gemfile
|
76
75
|
- gemfiles/5.1.gemfile
|
77
76
|
- gemfiles/5.2.gemfile
|
77
|
+
- gemfiles/6.0.gemfile
|
78
|
+
- gemfiles/6.1.gemfile
|
79
|
+
- gemfiles/7.0.gemfile
|
80
|
+
- gemfiles/7.1.gemfile
|
78
81
|
- lib/activerecord-import.rb
|
79
82
|
- lib/activerecord-import/active_record/adapters/abstract_adapter.rb
|
80
83
|
- lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb
|
@@ -84,12 +87,14 @@ files:
|
|
84
87
|
- lib/activerecord-import/active_record/adapters/postgresql_adapter.rb
|
85
88
|
- lib/activerecord-import/active_record/adapters/seamless_database_pool_adapter.rb
|
86
89
|
- lib/activerecord-import/active_record/adapters/sqlite3_adapter.rb
|
90
|
+
- lib/activerecord-import/active_record/adapters/trilogy_adapter.rb
|
87
91
|
- lib/activerecord-import/adapters/abstract_adapter.rb
|
88
92
|
- lib/activerecord-import/adapters/em_mysql2_adapter.rb
|
89
93
|
- lib/activerecord-import/adapters/mysql2_adapter.rb
|
90
94
|
- lib/activerecord-import/adapters/mysql_adapter.rb
|
91
95
|
- lib/activerecord-import/adapters/postgresql_adapter.rb
|
92
96
|
- lib/activerecord-import/adapters/sqlite3_adapter.rb
|
97
|
+
- lib/activerecord-import/adapters/trilogy_adapter.rb
|
93
98
|
- lib/activerecord-import/base.rb
|
94
99
|
- lib/activerecord-import/import.rb
|
95
100
|
- lib/activerecord-import/mysql2.rb
|
@@ -111,7 +116,9 @@ files:
|
|
111
116
|
- test/adapters/seamless_database_pool.rb
|
112
117
|
- test/adapters/spatialite.rb
|
113
118
|
- test/adapters/sqlite3.rb
|
119
|
+
- test/adapters/trilogy.rb
|
114
120
|
- test/database.yml.sample
|
121
|
+
- test/github/database.yml
|
115
122
|
- test/import_test.rb
|
116
123
|
- test/jdbcmysql/import_test.rb
|
117
124
|
- test/jdbcpostgresql/import_test.rb
|
@@ -119,18 +126,28 @@ files:
|
|
119
126
|
- test/makara_postgis/import_test.rb
|
120
127
|
- test/models/account.rb
|
121
128
|
- test/models/alarm.rb
|
129
|
+
- test/models/animal.rb
|
130
|
+
- test/models/author.rb
|
122
131
|
- test/models/bike_maker.rb
|
123
132
|
- test/models/book.rb
|
124
133
|
- test/models/car.rb
|
134
|
+
- test/models/card.rb
|
125
135
|
- test/models/chapter.rb
|
136
|
+
- test/models/composite_book.rb
|
137
|
+
- test/models/composite_chapter.rb
|
138
|
+
- test/models/customer.rb
|
139
|
+
- test/models/deck.rb
|
126
140
|
- test/models/dictionary.rb
|
127
141
|
- test/models/discount.rb
|
128
142
|
- test/models/end_note.rb
|
129
143
|
- test/models/group.rb
|
144
|
+
- test/models/order.rb
|
145
|
+
- test/models/playing_card.rb
|
130
146
|
- test/models/promotion.rb
|
131
147
|
- test/models/question.rb
|
132
148
|
- test/models/rule.rb
|
133
149
|
- test/models/tag.rb
|
150
|
+
- test/models/tag_alias.rb
|
134
151
|
- test/models/topic.rb
|
135
152
|
- test/models/user.rb
|
136
153
|
- test/models/user_token.rb
|
@@ -146,6 +163,7 @@ files:
|
|
146
163
|
- test/schema/mysql2_schema.rb
|
147
164
|
- test/schema/postgis_schema.rb
|
148
165
|
- test/schema/postgresql_schema.rb
|
166
|
+
- test/schema/sqlite3_schema.rb
|
149
167
|
- test/schema/version.rb
|
150
168
|
- test/sqlite3/import_test.rb
|
151
169
|
- test/support/active_support/test_case_extensions.rb
|
@@ -160,12 +178,12 @@ files:
|
|
160
178
|
- test/support/sqlite3/import_examples.rb
|
161
179
|
- test/synchronize_test.rb
|
162
180
|
- test/test_helper.rb
|
163
|
-
- test/
|
181
|
+
- test/trilogy/import_test.rb
|
164
182
|
- test/value_sets_bytes_parser_test.rb
|
165
183
|
- test/value_sets_records_parser_test.rb
|
166
|
-
homepage:
|
184
|
+
homepage: https://github.com/zdennis/activerecord-import
|
167
185
|
licenses:
|
168
|
-
-
|
186
|
+
- MIT
|
169
187
|
metadata: {}
|
170
188
|
post_install_message:
|
171
189
|
rdoc_options: []
|
@@ -175,15 +193,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
193
|
requirements:
|
176
194
|
- - ">="
|
177
195
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
196
|
+
version: 2.4.0
|
179
197
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
198
|
requirements:
|
181
199
|
- - ">="
|
182
200
|
- !ruby/object:Gem::Version
|
183
201
|
version: '0'
|
184
202
|
requirements: []
|
185
|
-
|
186
|
-
rubygems_version: 2.6.13
|
203
|
+
rubygems_version: 3.0.3.1
|
187
204
|
signing_key:
|
188
205
|
specification_version: 4
|
189
206
|
summary: Bulk insert extension for ActiveRecord
|
@@ -201,7 +218,9 @@ test_files:
|
|
201
218
|
- test/adapters/seamless_database_pool.rb
|
202
219
|
- test/adapters/spatialite.rb
|
203
220
|
- test/adapters/sqlite3.rb
|
221
|
+
- test/adapters/trilogy.rb
|
204
222
|
- test/database.yml.sample
|
223
|
+
- test/github/database.yml
|
205
224
|
- test/import_test.rb
|
206
225
|
- test/jdbcmysql/import_test.rb
|
207
226
|
- test/jdbcpostgresql/import_test.rb
|
@@ -209,18 +228,28 @@ test_files:
|
|
209
228
|
- test/makara_postgis/import_test.rb
|
210
229
|
- test/models/account.rb
|
211
230
|
- test/models/alarm.rb
|
231
|
+
- test/models/animal.rb
|
232
|
+
- test/models/author.rb
|
212
233
|
- test/models/bike_maker.rb
|
213
234
|
- test/models/book.rb
|
214
235
|
- test/models/car.rb
|
236
|
+
- test/models/card.rb
|
215
237
|
- test/models/chapter.rb
|
238
|
+
- test/models/composite_book.rb
|
239
|
+
- test/models/composite_chapter.rb
|
240
|
+
- test/models/customer.rb
|
241
|
+
- test/models/deck.rb
|
216
242
|
- test/models/dictionary.rb
|
217
243
|
- test/models/discount.rb
|
218
244
|
- test/models/end_note.rb
|
219
245
|
- test/models/group.rb
|
246
|
+
- test/models/order.rb
|
247
|
+
- test/models/playing_card.rb
|
220
248
|
- test/models/promotion.rb
|
221
249
|
- test/models/question.rb
|
222
250
|
- test/models/rule.rb
|
223
251
|
- test/models/tag.rb
|
252
|
+
- test/models/tag_alias.rb
|
224
253
|
- test/models/topic.rb
|
225
254
|
- test/models/user.rb
|
226
255
|
- test/models/user_token.rb
|
@@ -236,6 +265,7 @@ test_files:
|
|
236
265
|
- test/schema/mysql2_schema.rb
|
237
266
|
- test/schema/postgis_schema.rb
|
238
267
|
- test/schema/postgresql_schema.rb
|
268
|
+
- test/schema/sqlite3_schema.rb
|
239
269
|
- test/schema/version.rb
|
240
270
|
- test/sqlite3/import_test.rb
|
241
271
|
- test/support/active_support/test_case_extensions.rb
|
@@ -250,6 +280,6 @@ test_files:
|
|
250
280
|
- test/support/sqlite3/import_examples.rb
|
251
281
|
- test/synchronize_test.rb
|
252
282
|
- test/test_helper.rb
|
253
|
-
- test/
|
283
|
+
- test/trilogy/import_test.rb
|
254
284
|
- test/value_sets_bytes_parser_test.rb
|
255
285
|
- test/value_sets_records_parser_test.rb
|
data/.travis.yml
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
rvm:
|
4
|
-
- 2.3.7
|
5
|
-
|
6
|
-
env:
|
7
|
-
global:
|
8
|
-
# https://github.com/discourse/discourse/blob/master/.travis.yml
|
9
|
-
- RUBY_GC_MALLOC_LIMIT=50000000
|
10
|
-
matrix:
|
11
|
-
- AR_VERSION=3.2
|
12
|
-
- AR_VERSION=4.0
|
13
|
-
- AR_VERSION=4.1
|
14
|
-
- AR_VERSION=4.2
|
15
|
-
- AR_VERSION=5.0
|
16
|
-
- AR_VERSION=5.1
|
17
|
-
- AR_VERSION=5.2
|
18
|
-
|
19
|
-
matrix:
|
20
|
-
include:
|
21
|
-
- rvm: jruby-9.1.14.0
|
22
|
-
env: AR_VERSION=4.2
|
23
|
-
|
24
|
-
script:
|
25
|
-
- bundle exec rake test:jdbcsqlite3
|
26
|
-
- bundle exec rake test:jdbcmysql
|
27
|
-
- bundle exec rake test:jdbcpostgresql
|
28
|
-
|
29
|
-
fast_finish: true
|
30
|
-
|
31
|
-
addons:
|
32
|
-
postgresql: "9.5"
|
33
|
-
apt:
|
34
|
-
sources:
|
35
|
-
- travis-ci/sqlite3
|
36
|
-
- mysql-5.7-trusty
|
37
|
-
packages:
|
38
|
-
- sqlite3
|
39
|
-
- mysql-server
|
40
|
-
- mysql-client
|
41
|
-
- postgresql-9.5-postgis-2.3
|
42
|
-
|
43
|
-
before_install:
|
44
|
-
- gem update --system
|
45
|
-
- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
|
46
|
-
- sudo mysql_upgrade
|
47
|
-
- sudo service mysql restart
|
48
|
-
|
49
|
-
before_script:
|
50
|
-
- mysql -e 'create database activerecord_import_test;'
|
51
|
-
- psql -c 'create database activerecord_import_test;' -U postgres
|
52
|
-
- psql activerecord_import_test -c 'create extension if not exists hstore;' -U postgres
|
53
|
-
- psql -c 'create extension if not exists postgis;' -U postgres
|
54
|
-
- psql -c 'create extension if not exists "uuid-ossp";' -U postgres
|
55
|
-
- cp test/travis/database.yml test/database.yml
|
56
|
-
|
57
|
-
script:
|
58
|
-
- bundle exec rake test:mysql2
|
59
|
-
- bundle exec rake test:mysql2_makara
|
60
|
-
- bundle exec rake test:mysql2spatial
|
61
|
-
- bundle exec rake test:postgis
|
62
|
-
- bundle exec rake test:postgresql
|
63
|
-
- bundle exec rake test:postgresql_makara
|
64
|
-
- bundle exec rake test:seamless_database_pool
|
65
|
-
- bundle exec rake test:spatialite
|
66
|
-
- bundle exec rake test:sqlite3
|
67
|
-
- bundle exec rubocop
|
68
|
-
|
69
|
-
dist: trusty
|
70
|
-
|
71
|
-
sudo: required
|
data/gemfiles/3.2.gemfile
DELETED
data/gemfiles/4.0.gemfile
DELETED
data/gemfiles/4.1.gemfile
DELETED