activerecord-import 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yaml +19 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile +9 -1
- data/README.markdown +23 -0
- data/Rakefile +1 -0
- data/lib/activerecord-import/active_record/adapters/trilogy_adapter.rb +8 -0
- data/lib/activerecord-import/adapters/trilogy_adapter.rb +7 -0
- data/lib/activerecord-import/import.rb +1 -1
- data/lib/activerecord-import/version.rb +1 -1
- data/test/adapters/trilogy.rb +9 -0
- data/test/database.yml.sample +5 -0
- data/test/github/database.yml +4 -0
- data/test/support/shared_examples/on_duplicate_key_update.rb +28 -0
- data/test/trilogy/import_test.rb +7 -0
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32b6a19035fc43e21eeb0c6750e622a2605daf865b05aa9d551a697768456595
|
4
|
+
data.tar.gz: 7ba72ad6b48a05f52299bf6a49a487c880c82beacda25c6d6d6510a2d87bdf47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac0cb801e0c0883ec3f09432cb500c919fda756c22b6a4fb29bf3e0ecb3ce0aa0a8700e1112ff9340c9f5f7cdb756618eeba5dcae1ce06602216d21c82506ae4
|
7
|
+
data.tar.gz: 572f5ea800559cb5fa928d1c82f4e1ef03edac7d1bed5e4bb2849423fdd8fc01bf235f829ef2ab1d230de8832e0d078615e60fc8feb8a48a92f74bb94e7b23a9
|
data/.github/workflows/test.yaml
CHANGED
@@ -16,6 +16,20 @@ jobs:
|
|
16
16
|
--health-interval 10s
|
17
17
|
--health-timeout 5s
|
18
18
|
--health-retries 5
|
19
|
+
mysql:
|
20
|
+
image: mysql:5.7
|
21
|
+
ports:
|
22
|
+
- 3306:3306
|
23
|
+
env:
|
24
|
+
MYSQL_ROOT_PASSWORD: root
|
25
|
+
MYSQL_USER: github
|
26
|
+
MYSQL_PASSWORD: github
|
27
|
+
MYSQL_DATABASE: activerecord_import_test
|
28
|
+
options: >-
|
29
|
+
--health-cmd "mysqladmin ping -h localhost"
|
30
|
+
--health-interval 10s
|
31
|
+
--health-timeout 5s
|
32
|
+
--health-retries 5
|
19
33
|
strategy:
|
20
34
|
fail-fast: false
|
21
35
|
matrix:
|
@@ -44,7 +58,7 @@ jobs:
|
|
44
58
|
- ruby: '3.0'
|
45
59
|
env:
|
46
60
|
AR_VERSION: 6.1
|
47
|
-
- ruby: jruby
|
61
|
+
- ruby: jruby-9.4.5.0
|
48
62
|
env:
|
49
63
|
AR_VERSION: '7.0'
|
50
64
|
- ruby: 2.7
|
@@ -81,6 +95,7 @@ jobs:
|
|
81
95
|
with:
|
82
96
|
ruby-version: ${{ matrix.ruby }}
|
83
97
|
bundler-cache: true
|
98
|
+
rubygems: latest
|
84
99
|
- name: Set up databases
|
85
100
|
run: |
|
86
101
|
sudo /etc/init.d/mysql start
|
@@ -110,6 +125,9 @@ jobs:
|
|
110
125
|
run: |
|
111
126
|
bundle exec rake test:spatialite
|
112
127
|
bundle exec rake test:sqlite3
|
128
|
+
- name: Run trilogy tests
|
129
|
+
if: ${{ matrix.env.AR_VERSION >= '7.0' && matrix.ruby != 'jruby' }}
|
130
|
+
run: bundle exec rake test:trilogy
|
113
131
|
lint:
|
114
132
|
runs-on: ubuntu-latest
|
115
133
|
env:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## Changes in 1.6.0
|
2
|
+
|
3
|
+
### New Features
|
4
|
+
|
5
|
+
* Add trilogy adapter support. Thanks to @zmariscal via \##825.
|
6
|
+
|
7
|
+
### Fixes
|
8
|
+
|
9
|
+
* Use the locking_enabled? method provided by activerecord to decide whether the lock field should be updated. Thanks to @dombesz via \##822.
|
10
|
+
|
1
11
|
## Changes in 1.5.1
|
2
12
|
|
3
13
|
### Fixes
|
data/Gemfile
CHANGED
@@ -26,6 +26,10 @@ platforms :ruby do
|
|
26
26
|
gem "sqlite3", "~> #{sqlite3_version}"
|
27
27
|
# seamless_database_pool requires Ruby ~> 2.0
|
28
28
|
gem "seamless_database_pool", "~> 1.0.20" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')
|
29
|
+
gem "trilogy" if version >= 6.0
|
30
|
+
if version >= 6.0 && version <= 7.0
|
31
|
+
gem "activerecord-trilogy-adapter"
|
32
|
+
end
|
29
33
|
end
|
30
34
|
|
31
35
|
platforms :jruby do
|
@@ -37,7 +41,11 @@ platforms :jruby do
|
|
37
41
|
end
|
38
42
|
|
39
43
|
# Support libs
|
40
|
-
|
44
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0")
|
45
|
+
gem "factory_bot"
|
46
|
+
else
|
47
|
+
gem "factory_bot", "~> 5", "< 6.4.5"
|
48
|
+
end
|
41
49
|
gem "timecop"
|
42
50
|
gem "chronic"
|
43
51
|
gem "mocha", "~> 2.1.0"
|
data/README.markdown
CHANGED
@@ -364,6 +364,29 @@ book.reload.title # => "Book1" (stayed the same)
|
|
364
364
|
book.reload.author # => "Bob Barker" (changed)
|
365
365
|
```
|
366
366
|
|
367
|
+
PostgreSQL Using partial indexes
|
368
|
+
|
369
|
+
```ruby
|
370
|
+
book = Book.create! title: "Book1", author: "George Orwell", published_at: Time.now
|
371
|
+
book.author = "Bob Barker"
|
372
|
+
|
373
|
+
# in migration
|
374
|
+
execute <<-SQL
|
375
|
+
CREATE INDEX books_published_at_index ON books (published_at) WHERE published_at IS NOT NULL;
|
376
|
+
SQL
|
377
|
+
|
378
|
+
# PostgreSQL version
|
379
|
+
Book.import [book], on_duplicate_key_update: {
|
380
|
+
conflict_target: [:id],
|
381
|
+
index_predicate: "published_at IS NOT NULL",
|
382
|
+
columns: [:author]
|
383
|
+
}
|
384
|
+
|
385
|
+
book.reload.title # => "Book1" (stayed the same)
|
386
|
+
book.reload.author # => "Bob Barker" (changed)
|
387
|
+
book.reload.published_at # => 2017-10-09 (stayed the same)
|
388
|
+
```
|
389
|
+
|
367
390
|
PostgreSQL Using constraints
|
368
391
|
|
369
392
|
```ruby
|
data/Rakefile
CHANGED
@@ -557,7 +557,7 @@ class ActiveRecord::Base
|
|
557
557
|
options.merge!( args.pop ) if args.last.is_a? Hash
|
558
558
|
# making sure that current model's primary key is used
|
559
559
|
options[:primary_key] = primary_key
|
560
|
-
options[:locking_column] = locking_column if
|
560
|
+
options[:locking_column] = locking_column if locking_enabled?
|
561
561
|
|
562
562
|
is_validating = options[:validate_with_context].present? ? true : options[:validate]
|
563
563
|
validator = ActiveRecord::Import::Validator.new(self, options)
|
data/test/database.yml.sample
CHANGED
data/test/github/database.yml
CHANGED
@@ -223,6 +223,34 @@ def should_support_basic_on_duplicate_key_update
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
end
|
226
|
+
|
227
|
+
context 'with locking disabled' do
|
228
|
+
it 'does not update the lock_version' do
|
229
|
+
users = [
|
230
|
+
User.new(name: 'Salomon'),
|
231
|
+
User.new(name: 'Nathan')
|
232
|
+
]
|
233
|
+
User.import(users)
|
234
|
+
assert User.count == users.length
|
235
|
+
User.all.each do |user|
|
236
|
+
assert_equal 0, user.lock_version
|
237
|
+
end
|
238
|
+
updated_users = User.all.map do |user|
|
239
|
+
user.name += ' Rothschild'
|
240
|
+
user
|
241
|
+
end
|
242
|
+
|
243
|
+
ActiveRecord::Base.lock_optimistically = false # Disable locking
|
244
|
+
User.import(updated_users, on_duplicate_key_update: [:name])
|
245
|
+
ActiveRecord::Base.lock_optimistically = true # Enable locking
|
246
|
+
|
247
|
+
assert User.count == updated_users.length
|
248
|
+
User.all.each_with_index do |user, i|
|
249
|
+
assert_equal user.name, "#{users[i].name} Rothschild"
|
250
|
+
assert_equal 0, user.lock_version
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
226
254
|
end
|
227
255
|
|
228
256
|
context "with :on_duplicate_key_update" do
|
@@ -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: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -87,12 +87,14 @@ files:
|
|
87
87
|
- lib/activerecord-import/active_record/adapters/postgresql_adapter.rb
|
88
88
|
- lib/activerecord-import/active_record/adapters/seamless_database_pool_adapter.rb
|
89
89
|
- lib/activerecord-import/active_record/adapters/sqlite3_adapter.rb
|
90
|
+
- lib/activerecord-import/active_record/adapters/trilogy_adapter.rb
|
90
91
|
- lib/activerecord-import/adapters/abstract_adapter.rb
|
91
92
|
- lib/activerecord-import/adapters/em_mysql2_adapter.rb
|
92
93
|
- lib/activerecord-import/adapters/mysql2_adapter.rb
|
93
94
|
- lib/activerecord-import/adapters/mysql_adapter.rb
|
94
95
|
- lib/activerecord-import/adapters/postgresql_adapter.rb
|
95
96
|
- lib/activerecord-import/adapters/sqlite3_adapter.rb
|
97
|
+
- lib/activerecord-import/adapters/trilogy_adapter.rb
|
96
98
|
- lib/activerecord-import/base.rb
|
97
99
|
- lib/activerecord-import/import.rb
|
98
100
|
- lib/activerecord-import/mysql2.rb
|
@@ -114,6 +116,7 @@ files:
|
|
114
116
|
- test/adapters/seamless_database_pool.rb
|
115
117
|
- test/adapters/spatialite.rb
|
116
118
|
- test/adapters/sqlite3.rb
|
119
|
+
- test/adapters/trilogy.rb
|
117
120
|
- test/database.yml.sample
|
118
121
|
- test/github/database.yml
|
119
122
|
- test/import_test.rb
|
@@ -172,13 +175,14 @@ files:
|
|
172
175
|
- test/support/sqlite3/import_examples.rb
|
173
176
|
- test/synchronize_test.rb
|
174
177
|
- test/test_helper.rb
|
178
|
+
- test/trilogy/import_test.rb
|
175
179
|
- test/value_sets_bytes_parser_test.rb
|
176
180
|
- test/value_sets_records_parser_test.rb
|
177
181
|
homepage: https://github.com/zdennis/activerecord-import
|
178
182
|
licenses:
|
179
183
|
- MIT
|
180
184
|
metadata: {}
|
181
|
-
post_install_message:
|
185
|
+
post_install_message:
|
182
186
|
rdoc_options: []
|
183
187
|
require_paths:
|
184
188
|
- lib
|
@@ -193,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
197
|
- !ruby/object:Gem::Version
|
194
198
|
version: '0'
|
195
199
|
requirements: []
|
196
|
-
rubygems_version: 3.3.
|
197
|
-
signing_key:
|
200
|
+
rubygems_version: 3.0.3.1
|
201
|
+
signing_key:
|
198
202
|
specification_version: 4
|
199
203
|
summary: Bulk insert extension for ActiveRecord
|
200
204
|
test_files:
|
@@ -211,6 +215,7 @@ test_files:
|
|
211
215
|
- test/adapters/seamless_database_pool.rb
|
212
216
|
- test/adapters/spatialite.rb
|
213
217
|
- test/adapters/sqlite3.rb
|
218
|
+
- test/adapters/trilogy.rb
|
214
219
|
- test/database.yml.sample
|
215
220
|
- test/github/database.yml
|
216
221
|
- test/import_test.rb
|
@@ -269,5 +274,6 @@ test_files:
|
|
269
274
|
- test/support/sqlite3/import_examples.rb
|
270
275
|
- test/synchronize_test.rb
|
271
276
|
- test/test_helper.rb
|
277
|
+
- test/trilogy/import_test.rb
|
272
278
|
- test/value_sets_bytes_parser_test.rb
|
273
279
|
- test/value_sets_records_parser_test.rb
|