activerecord-import 1.1.0 → 1.4.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 +107 -0
- data/CHANGELOG.md +32 -3
- data/Gemfile +2 -6
- data/README.markdown +11 -10
- data/activerecord-import.gemspec +2 -2
- data/benchmarks/benchmark.rb +5 -1
- data/gemfiles/6.1.gemfile +1 -0
- data/gemfiles/7.0.gemfile +1 -0
- data/lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb +4 -4
- data/lib/activerecord-import/adapters/mysql_adapter.rb +1 -1
- data/lib/activerecord-import/adapters/postgresql_adapter.rb +4 -6
- data/lib/activerecord-import/adapters/sqlite3_adapter.rb +4 -6
- data/lib/activerecord-import/import.rb +41 -22
- data/lib/activerecord-import/synchronize.rb +1 -1
- data/lib/activerecord-import/version.rb +1 -1
- data/test/{travis → github}/database.yml +3 -1
- data/test/import_test.rb +24 -2
- data/test/models/card.rb +3 -0
- data/test/models/customer.rb +6 -0
- data/test/models/deck.rb +6 -0
- data/test/models/order.rb +6 -0
- data/test/models/playing_card.rb +2 -0
- data/test/schema/generic_schema.rb +25 -0
- data/test/support/postgresql/import_examples.rb +25 -1
- data/test/support/shared_examples/recursive_import.rb +21 -1
- data/test/test_helper.rb +11 -2
- metadata +23 -15
- data/.travis.yml +0 -76
- data/gemfiles/3.2.gemfile +0 -2
- data/gemfiles/4.0.gemfile +0 -2
- data/gemfiles/4.1.gemfile +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71623b61f085adce5254fc92ae524f595594cb5a960bb4bf0cb46d961ca9d203
|
4
|
+
data.tar.gz: ce2200678685afd85dc0a887d967bae7e2e4220942ab2f8fc34bb949b8f5a31b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71bdd79b977164223d77c77ec796ac3914124318bb377c8aa044bc8085d0f7ba9536e35b99b6a670b0a4c825e4dfe49aef5a10626b92109b2ce7dd8cd529dbb1
|
7
|
+
data.tar.gz: 89db7ca7f321a473391d2083a2dc6cb4fe8614069441c2a16601a0a3e4ab848e889eafba67b53fc2042d60b7095aab50926f4795d07930c0c90820527f07c28c
|
@@ -0,0 +1,107 @@
|
|
1
|
+
name: Test
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
services:
|
6
|
+
postgres:
|
7
|
+
image: postgis/postgis:10-2.5
|
8
|
+
env:
|
9
|
+
POSTGRES_USER: postgres
|
10
|
+
POSTGRES_PASSWORD: postgres
|
11
|
+
ports:
|
12
|
+
- 5432:5432
|
13
|
+
# Set health checks to wait until postgres has started
|
14
|
+
options: >-
|
15
|
+
--health-cmd pg_isready
|
16
|
+
--health-interval 10s
|
17
|
+
--health-timeout 5s
|
18
|
+
--health-retries 5
|
19
|
+
strategy:
|
20
|
+
fail-fast: false
|
21
|
+
matrix:
|
22
|
+
ruby:
|
23
|
+
- 3.1
|
24
|
+
env:
|
25
|
+
- AR_VERSION: '7.0'
|
26
|
+
RUBYOPT: --enable-frozen-string-literal
|
27
|
+
- AR_VERSION: 6.1
|
28
|
+
RUBYOPT: --enable-frozen-string-literal
|
29
|
+
include:
|
30
|
+
- ruby: '3.0'
|
31
|
+
env:
|
32
|
+
AR_VERSION: '7.0'
|
33
|
+
- ruby: '3.0'
|
34
|
+
env:
|
35
|
+
AR_VERSION: 6.1
|
36
|
+
- ruby: 2.7
|
37
|
+
env:
|
38
|
+
AR_VERSION: '7.0'
|
39
|
+
- ruby: 2.7
|
40
|
+
env:
|
41
|
+
AR_VERSION: 6.1
|
42
|
+
- ruby: 2.7
|
43
|
+
env:
|
44
|
+
AR_VERSION: '6.0'
|
45
|
+
- ruby: 2.6
|
46
|
+
env:
|
47
|
+
AR_VERSION: 5.2
|
48
|
+
- ruby: 2.6
|
49
|
+
env:
|
50
|
+
AR_VERSION: 5.1
|
51
|
+
- ruby: 2.4
|
52
|
+
env:
|
53
|
+
AR_VERSION: '5.0'
|
54
|
+
- ruby: 2.4
|
55
|
+
env:
|
56
|
+
AR_VERSION: 4.2
|
57
|
+
runs-on: ubuntu-latest
|
58
|
+
env:
|
59
|
+
AR_VERSION: ${{ matrix.env.AR_VERSION }}
|
60
|
+
DB_DATABASE: activerecord_import_test
|
61
|
+
steps:
|
62
|
+
- uses: actions/checkout@v2
|
63
|
+
- uses: ruby/setup-ruby@v1
|
64
|
+
with:
|
65
|
+
ruby-version: ${{ matrix.ruby }}
|
66
|
+
bundler-cache: true
|
67
|
+
- name: Set up databases
|
68
|
+
run: |
|
69
|
+
sudo /etc/init.d/mysql start
|
70
|
+
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }} CHARACTER SET utf8 COLLATE utf8_general_ci;' -u root -proot
|
71
|
+
psql -h localhost -U postgres -c 'create database ${{ env.DB_DATABASE }};'
|
72
|
+
psql -h localhost -U postgres -d ${{ env.DB_DATABASE }} -c 'create extension if not exists hstore;'
|
73
|
+
psql -h localhost -U postgres -c 'create extension if not exists postgis;'
|
74
|
+
psql -h localhost -U postgres -c 'create extension if not exists "uuid-ossp";'
|
75
|
+
cp test/github/database.yml test/database.yml
|
76
|
+
env:
|
77
|
+
PGPASSWORD: postgres
|
78
|
+
- name: Run tests with mysql2
|
79
|
+
run: |
|
80
|
+
bundle exec rake test:mysql2
|
81
|
+
bundle exec rake test:mysql2_makara
|
82
|
+
bundle exec rake test:mysql2spatial
|
83
|
+
- name: Run tests with postgresql
|
84
|
+
run: |
|
85
|
+
bundle exec rake test:postgis
|
86
|
+
bundle exec rake test:postgresql
|
87
|
+
bundle exec rake test:postgresql_makara
|
88
|
+
- name: Run tests with seamless_database_pool
|
89
|
+
run: |
|
90
|
+
bundle exec rake test:seamless_database_pool
|
91
|
+
if: ${{ matrix.ruby < '3.0' }}
|
92
|
+
- name: Run tests with sqlite
|
93
|
+
run: |
|
94
|
+
bundle exec rake test:spatialite
|
95
|
+
bundle exec rake test:sqlite3
|
96
|
+
lint:
|
97
|
+
runs-on: ubuntu-latest
|
98
|
+
env:
|
99
|
+
AR_VERSION: '7.0'
|
100
|
+
steps:
|
101
|
+
- uses: actions/checkout@v2
|
102
|
+
- uses: ruby/setup-ruby@v1
|
103
|
+
with:
|
104
|
+
ruby-version: 2.7
|
105
|
+
bundler-cache: true
|
106
|
+
- name: Run Rubocop
|
107
|
+
run: bundle exec rubocop
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
## Changes in 1.4.0
|
2
|
+
|
3
|
+
### New Features
|
4
|
+
|
5
|
+
* Enable compatibility with frozen string literals. Thanks to @desheikh via \##760.
|
6
|
+
|
7
|
+
## Changes in 1.3.0
|
8
|
+
|
9
|
+
### Fixes
|
10
|
+
|
11
|
+
* Ensure correct timestamp values are returned for models after insert. Thanks to @kos1kov via \##756.
|
12
|
+
* Restore database_version method to public scope. Thanks to @beauraF via \##753.
|
13
|
+
|
14
|
+
### New Features
|
15
|
+
|
16
|
+
* Add support for ActiveRecord 7.0. Thanks to @nickhammond, @ryanwood, @jkowens via \##749 and \##752.
|
17
|
+
* Add support for compound foreign keys. Thanks to @Uladzimiro via \##750.
|
18
|
+
* Add support for :recursive combined with on_duplicate_key_update: :all. Thanks to @deathwish via \##746.
|
19
|
+
|
20
|
+
## Changes in 1.2.0
|
21
|
+
|
22
|
+
### Fixes
|
23
|
+
|
24
|
+
* Update JDBC MySQL adapter to use mysql2 connection adapter. Thanks to @terencechow via \##744.
|
25
|
+
* Fix importing STI models with ActiveRecord 6. Thanks to @clemens1483 via \##743.
|
26
|
+
* Use polymorphic_name instead of base_class.name for imports. Thanks to @kmhajjar via \##741.
|
27
|
+
* Fix compatibility issue with composite primary keys. Thanks to @dlanileonardo via \##737.
|
28
|
+
* Prevent double validation of associations on recursive import.
|
29
|
+
|
1
30
|
## Changes in 1.1.0
|
2
31
|
|
3
32
|
### New Features
|
@@ -27,7 +56,7 @@
|
|
27
56
|
|
28
57
|
* Handle after_initialize callbacks. Thanks to @AhMohsen46 via \#691 and
|
29
58
|
\#692.
|
30
|
-
* Fix regression introduced in 1.0.4.
|
59
|
+
* Fix regression introduced in 1.0.4. Explicitly allow adapters to
|
31
60
|
support on duplicate key update. Thanks to @dsobiera, @jkowens via \#696.
|
32
61
|
|
33
62
|
## Changes in 1.0.5
|
@@ -36,7 +65,7 @@
|
|
36
65
|
|
37
66
|
* Allow serialized attributes to be returned from import. Thanks to @timanovsky, @jkowens via \#660.
|
38
67
|
* Return ActiveRecord::Connection from
|
39
|
-
|
68
|
+
ActiveRecord::Base#establish_connection. Thanks to @reverentF via
|
40
69
|
\#663.
|
41
70
|
* Support PostgreSQL array. Thanks to @ujihisa via \#669.
|
42
71
|
* Skip loading association ids when column changed. Thanks to @Aristat
|
@@ -91,7 +120,7 @@
|
|
91
120
|
* Fix import issue for models with Postgresql json/jsonb fields. Thanks
|
92
121
|
to @stokarenko via \#594.
|
93
122
|
* Fix issue importing models with timestamps that contain timezone
|
94
|
-
information.
|
123
|
+
information. Thanks to @dekaikiwi, @jkowens via \#598.
|
95
124
|
* Ignore :no_returning when using :recursive option. Thanks to @dgollahon, @jkowens
|
96
125
|
via \#599.
|
97
126
|
|
data/Gemfile
CHANGED
@@ -22,7 +22,8 @@ platforms :ruby do
|
|
22
22
|
gem "mysql2", "~> #{mysql2_version}"
|
23
23
|
gem "pg", "~> #{pg_version}"
|
24
24
|
gem "sqlite3", "~> #{sqlite3_version}"
|
25
|
-
|
25
|
+
# seamless_database_pool requires Ruby ~> 2.0
|
26
|
+
gem "seamless_database_pool", "~> 1.0.20" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')
|
26
27
|
end
|
27
28
|
|
28
29
|
platforms :jruby do
|
@@ -44,14 +45,9 @@ platforms :jruby do
|
|
44
45
|
gem "ruby-debug", "= 0.10.4"
|
45
46
|
end
|
46
47
|
|
47
|
-
platforms :mri_19 do
|
48
|
-
gem "debugger"
|
49
|
-
end
|
50
|
-
|
51
48
|
platforms :ruby do
|
52
49
|
gem "pry-byebug"
|
53
50
|
gem "pry", "~> 0.12.0"
|
54
|
-
gem "rb-readline"
|
55
51
|
end
|
56
52
|
|
57
53
|
if version >= 4.0
|
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Activerecord-Import
|
1
|
+
# Activerecord-Import ![Build Status](https://github.com/zdennis/activerecord-import/actions/workflows/test.yaml/badge.svg)
|
2
2
|
|
3
3
|
Activerecord-Import is a library for bulk inserting data using ActiveRecord.
|
4
4
|
|
@@ -266,8 +266,8 @@ Key | Options | Default | Descrip
|
|
266
266
|
------------------------- | --------------------- | ------------------ | -----------
|
267
267
|
:validate | `true`/`false` | `true` | Whether or not to run `ActiveRecord` validations (uniqueness skipped). This option will always be true when using `import!`.
|
268
268
|
:validate_uniqueness | `true`/`false` | `false` | Whether or not to run uniqueness validations, has potential pitfalls, use with caution (requires `>= v0.27.0`).
|
269
|
-
:validate_with_context | `Symbol` |`:create`/`:update` | Allows passing an ActiveModel validation context for each model. Default is `:create` for new records and `:update` for existing ones.
|
270
|
-
:track_validation_failures| `true`/`false` | `false` | When this is set to true, `failed_instances` will be an array of arrays, with each inner array having the form `[:index_in_dataset, :object_with_errors]`
|
269
|
+
:validate_with_context | `Symbol` |`:create`/`:update` | Allows passing an ActiveModel validation context for each model. Default is `:create` for new records and `:update` for existing ones.
|
270
|
+
:track_validation_failures| `true`/`false` | `false` | When this is set to true, `failed_instances` will be an array of arrays, with each inner array having the form `[:index_in_dataset, :object_with_errors]`
|
271
271
|
:on_duplicate_key_ignore | `true`/`false` | `false` | Allows skipping records with duplicate keys. See [here](https://github.com/zdennis/activerecord-import/#duplicate-key-ignore) for more details.
|
272
272
|
:ignore | `true`/`false` | `false` | Alias for :on_duplicate_key_ignore.
|
273
273
|
:on_duplicate_key_update | :all, `Array`, `Hash` | N/A | Allows upsert logic to be used. See [here](https://github.com/zdennis/activerecord-import/#duplicate-key-update) for more details.
|
@@ -392,7 +392,7 @@ Book.import books, validate_uniqueness: true
|
|
392
392
|
|
393
393
|
### Return Info
|
394
394
|
|
395
|
-
The `import` method returns a `Result` object that responds to `failed_instances` and `num_inserts`. Additionally, for users of Postgres, there will be two arrays `ids` and `results` that can be accessed
|
395
|
+
The `import` method returns a `Result` object that responds to `failed_instances` and `num_inserts`. Additionally, for users of Postgres, there will be two arrays `ids` and `results` that can be accessed.
|
396
396
|
|
397
397
|
```ruby
|
398
398
|
articles = [
|
@@ -433,7 +433,8 @@ Should you wish to specify those columns, you may use the option `timestamps: fa
|
|
433
433
|
|
434
434
|
However, it is also possible to set just `:created_at` in specific records. In this case despite using `timestamps: true`, `:created_at` will be updated only in records where that field is `nil`. Same rule applies for record associations when enabling the option `recursive: true`.
|
435
435
|
|
436
|
-
If you are using custom time zones, these will be respected when performing imports as well as long as `ActiveRecord::Base.default_timezone` is set, which for practically all Rails apps it is
|
436
|
+
If you are using custom time zones, these will be respected when performing imports as well as long as `ActiveRecord::Base.default_timezone` is set, which for practically all Rails apps it is.
|
437
|
+
NOTE: If you are using ActiveRecord 7.0 or later, please use `ActiveRecord.default_timezone` instead.
|
437
438
|
|
438
439
|
### Callbacks
|
439
440
|
|
@@ -572,7 +573,7 @@ When rubygems pushes the `lib` folder onto the load path a `require` will now fi
|
|
572
573
|
|
573
574
|
Activerecord-Import adds the `.import` method onto `ActiveRecord::Base`. There are other gems, such as `elasticsearch-rails`, that do the same thing. In conflicts such as this, there is an aliased method named `.bulk_import` that can be used interchangeably.
|
574
575
|
|
575
|
-
If you are using the `apartment` gem, there is a weird triple interaction between that gem, `activerecord-import`, and `activerecord` involving caching of the `sequence_name` of a model. This can be worked around by
|
576
|
+
If you are using the `apartment` gem, there is a weird triple interaction between that gem, `activerecord-import`, and `activerecord` involving caching of the `sequence_name` of a model. This can be worked around by explicitly setting this value within the model. For example:
|
576
577
|
|
577
578
|
```ruby
|
578
579
|
class Post < ActiveRecord::Base
|
@@ -615,13 +616,13 @@ After that, you can run the tests. They run against multiple tests and ActiveRec
|
|
615
616
|
|
616
617
|
This is one example of how to run the tests:
|
617
618
|
|
618
|
-
```
|
619
|
+
```bash
|
619
620
|
rm Gemfile.lock
|
620
|
-
AR_VERSION=
|
621
|
-
AR_VERSION=
|
621
|
+
AR_VERSION=7.0 bundle install
|
622
|
+
AR_VERSION=7.0 bundle exec rake test:postgresql test:sqlite3 test:mysql2
|
622
623
|
```
|
623
624
|
|
624
|
-
Once you have pushed up your changes, you can find your CI results [here](https://
|
625
|
+
Once you have pushed up your changes, you can find your CI results [here](https://github.com/zdennis/activerecord-import/actions).
|
625
626
|
|
626
627
|
## Issue Triage [![Open Source Helpers](https://www.codetriage.com/zdennis/activerecord-import/badges/users.svg)](https://www.codetriage.com/zdennis/activerecord-import)
|
627
628
|
|
data/activerecord-import.gemspec
CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = ActiveRecord::Import::VERSION
|
18
18
|
|
19
|
-
gem.required_ruby_version = ">= 2.
|
19
|
+
gem.required_ruby_version = ">= 2.4.0"
|
20
20
|
|
21
|
-
gem.add_runtime_dependency "activerecord", ">=
|
21
|
+
gem.add_runtime_dependency "activerecord", ">= 4.2"
|
22
22
|
gem.add_development_dependency "rake"
|
23
23
|
end
|
data/benchmarks/benchmark.rb
CHANGED
@@ -20,7 +20,11 @@ FileUtils.mkdir_p 'log'
|
|
20
20
|
ActiveRecord::Base.configurations["test"] = YAML.load_file(File.join(benchmark_dir, "../test/database.yml"))[options.adapter]
|
21
21
|
ActiveRecord::Base.logger = Logger.new("log/test.log")
|
22
22
|
ActiveRecord::Base.logger.level = Logger::DEBUG
|
23
|
-
ActiveRecord
|
23
|
+
if ActiveRecord.respond_to?(:default_timezone)
|
24
|
+
ActiveRecord.default_timezone = :utc
|
25
|
+
else
|
26
|
+
ActiveRecord::Base.default_timezone = :utc
|
27
|
+
end
|
24
28
|
|
25
29
|
require "activerecord-import"
|
26
30
|
ActiveRecord::Base.establish_connection(:test)
|
data/gemfiles/6.1.gemfile
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
gem 'activerecord', '~> 7.0.0'
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require "active_record/connection_adapters/
|
2
|
-
require "activerecord-import/adapters/
|
1
|
+
require "active_record/connection_adapters/mysql2_adapter"
|
2
|
+
require "activerecord-import/adapters/mysql2_adapter"
|
3
3
|
|
4
|
-
class ActiveRecord::ConnectionAdapters::
|
5
|
-
include ActiveRecord::Import::
|
4
|
+
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
5
|
+
include ActiveRecord::Import::Mysql2Adapter
|
6
6
|
end
|
@@ -82,7 +82,7 @@ module ActiveRecord::Import::MysqlAdapter
|
|
82
82
|
# Returns a generated ON DUPLICATE KEY UPDATE statement given the passed
|
83
83
|
# in +args+.
|
84
84
|
def sql_for_on_duplicate_key_update( table_name, *args ) # :nodoc:
|
85
|
-
sql = ' ON DUPLICATE KEY UPDATE '
|
85
|
+
sql = ' ON DUPLICATE KEY UPDATE '.dup
|
86
86
|
arg = args.first
|
87
87
|
locking_column = args.last
|
88
88
|
if arg.is_a?( Array )
|
@@ -123,7 +123,7 @@ module ActiveRecord::Import::PostgreSQLAdapter
|
|
123
123
|
arg = { columns: arg } if arg.is_a?( Array ) || arg.is_a?( String )
|
124
124
|
return unless arg.is_a?( Hash )
|
125
125
|
|
126
|
-
sql = ' ON CONFLICT '
|
126
|
+
sql = ' ON CONFLICT '.dup
|
127
127
|
conflict_target = sql_for_conflict_target( arg )
|
128
128
|
|
129
129
|
columns = arg.fetch( :columns, [] )
|
@@ -179,9 +179,9 @@ module ActiveRecord::Import::PostgreSQLAdapter
|
|
179
179
|
if constraint_name.present?
|
180
180
|
"ON CONSTRAINT #{constraint_name} "
|
181
181
|
elsif conflict_target.present?
|
182
|
-
'('
|
183
|
-
|
184
|
-
|
182
|
+
sql = '(' + Array( conflict_target ).reject( &:blank? ).join( ', ' ) + ') '
|
183
|
+
sql += "WHERE #{index_predicate} " if index_predicate
|
184
|
+
sql
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
@@ -203,8 +203,6 @@ module ActiveRecord::Import::PostgreSQLAdapter
|
|
203
203
|
true
|
204
204
|
end
|
205
205
|
|
206
|
-
private
|
207
|
-
|
208
206
|
def database_version
|
209
207
|
defined?(postgresql_version) ? postgresql_version : super
|
210
208
|
end
|
@@ -97,7 +97,7 @@ module ActiveRecord::Import::SQLite3Adapter
|
|
97
97
|
arg = { columns: arg } if arg.is_a?( Array ) || arg.is_a?( String )
|
98
98
|
return unless arg.is_a?( Hash )
|
99
99
|
|
100
|
-
sql = ' ON CONFLICT '
|
100
|
+
sql = ' ON CONFLICT '.dup
|
101
101
|
conflict_target = sql_for_conflict_target( arg )
|
102
102
|
|
103
103
|
columns = arg.fetch( :columns, [] )
|
@@ -150,9 +150,9 @@ module ActiveRecord::Import::SQLite3Adapter
|
|
150
150
|
conflict_target = args[:conflict_target]
|
151
151
|
index_predicate = args[:index_predicate]
|
152
152
|
if conflict_target.present?
|
153
|
-
'('
|
154
|
-
|
155
|
-
|
153
|
+
sql = '(' + Array( conflict_target ).reject( &:blank? ).join( ', ' ) + ') '
|
154
|
+
sql += "WHERE #{index_predicate} " if index_predicate
|
155
|
+
sql
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
@@ -166,8 +166,6 @@ module ActiveRecord::Import::SQLite3Adapter
|
|
166
166
|
exception.is_a?(ActiveRecord::StatementInvalid) && exception.to_s.include?('duplicate key')
|
167
167
|
end
|
168
168
|
|
169
|
-
private
|
170
|
-
|
171
169
|
def database_version
|
172
170
|
defined?(sqlite_version) ? sqlite_version : super
|
173
171
|
end
|
@@ -34,7 +34,7 @@ module ActiveRecord::Import #:nodoc:
|
|
34
34
|
@validate_callbacks = klass._validate_callbacks.dup
|
35
35
|
|
36
36
|
@validate_callbacks.each_with_index do |callback, i|
|
37
|
-
filter = callback.raw_filter
|
37
|
+
filter = callback.respond_to?(:raw_filter) ? callback.raw_filter : callback.filter
|
38
38
|
next unless filter.class.name =~ /Validations::PresenceValidator/ ||
|
39
39
|
(!@options[:validate_uniqueness] &&
|
40
40
|
filter.is_a?(ActiveRecord::Validations::UniquenessValidator))
|
@@ -49,7 +49,7 @@ module ActiveRecord::Import #:nodoc:
|
|
49
49
|
associations = klass.reflect_on_all_associations(:belongs_to)
|
50
50
|
associations.each do |assoc|
|
51
51
|
if (index = attrs.index(assoc.name))
|
52
|
-
key = assoc.foreign_key.to_sym
|
52
|
+
key = assoc.foreign_key.is_a?(Array) ? assoc.foreign_key.map(&:to_sym) : assoc.foreign_key.to_sym
|
53
53
|
attrs[index] = key unless attrs.include?(key)
|
54
54
|
end
|
55
55
|
end
|
@@ -734,7 +734,10 @@ class ActiveRecord::Base
|
|
734
734
|
set_attributes_and_mark_clean(models, return_obj, timestamps, options)
|
735
735
|
|
736
736
|
# if there are auto-save associations on the models we imported that are new, import them as well
|
737
|
-
|
737
|
+
if options[:recursive]
|
738
|
+
options[:on_duplicate_key_update] = on_duplicate_key_update unless on_duplicate_key_update.nil?
|
739
|
+
import_associations(models, options.dup.merge(validate: false))
|
740
|
+
end
|
738
741
|
end
|
739
742
|
|
740
743
|
return_obj
|
@@ -775,21 +778,22 @@ class ActiveRecord::Base
|
|
775
778
|
unless scope_columns.blank?
|
776
779
|
scope_columns.zip(scope_values).each do |name, value|
|
777
780
|
name_as_sym = name.to_sym
|
778
|
-
next if column_names.include?(name_as_sym)
|
779
|
-
|
780
|
-
is_sti = (name_as_sym == inheritance_column.to_sym && self < base_class)
|
781
|
-
value = Array(value).first if is_sti
|
782
|
-
|
781
|
+
next if column_names.include?(name_as_sym) || name_as_sym == inheritance_column.to_sym
|
783
782
|
column_names << name_as_sym
|
784
783
|
array_of_attributes.each { |attrs| attrs << value }
|
785
784
|
end
|
786
785
|
end
|
787
786
|
|
787
|
+
if finder_needs_type_condition?
|
788
|
+
unless column_names.include?(inheritance_column.to_sym)
|
789
|
+
column_names << inheritance_column.to_sym
|
790
|
+
array_of_attributes.each { |attrs| attrs << sti_name }
|
791
|
+
end
|
792
|
+
end
|
793
|
+
|
788
794
|
columns = column_names.each_with_index.map do |name, i|
|
789
795
|
column = columns_hash[name.to_s]
|
790
|
-
|
791
796
|
raise ActiveRecord::Import::MissingColumnError.new(name.to_s, i) if column.nil?
|
792
|
-
|
793
797
|
column
|
794
798
|
end
|
795
799
|
|
@@ -853,7 +857,7 @@ class ActiveRecord::Base
|
|
853
857
|
model.id = id
|
854
858
|
|
855
859
|
timestamps.each do |attr, value|
|
856
|
-
model.send(attr + "=", value)
|
860
|
+
model.send(attr + "=", value) if model.send(attr).nil?
|
857
861
|
end
|
858
862
|
end
|
859
863
|
end
|
@@ -907,15 +911,19 @@ class ActiveRecord::Base
|
|
907
911
|
changed_columns = model.changed
|
908
912
|
association_reflections = model.class.reflect_on_all_associations(:belongs_to)
|
909
913
|
association_reflections.each do |association_reflection|
|
910
|
-
column_name = association_reflection.foreign_key
|
911
914
|
next if association_reflection.options[:polymorphic]
|
912
|
-
next if changed_columns.include?(column_name)
|
913
|
-
association = model.association(association_reflection.name)
|
914
|
-
association = association.target
|
915
|
-
next if association.blank? || model.public_send(column_name).present?
|
916
915
|
|
917
|
-
|
918
|
-
|
916
|
+
column_names = Array(association_reflection.foreign_key).map(&:to_s)
|
917
|
+
column_names.each_with_index do |column_name, column_index|
|
918
|
+
next if changed_columns.include?(column_name)
|
919
|
+
|
920
|
+
association = model.association(association_reflection.name)
|
921
|
+
association = association.target
|
922
|
+
next if association.blank? || model.public_send(column_name).present?
|
923
|
+
|
924
|
+
association_primary_key = Array(association_reflection.association_primary_key)[column_index]
|
925
|
+
model.public_send("#{column_name}=", association.send(association_primary_key))
|
926
|
+
end
|
919
927
|
end
|
920
928
|
end
|
921
929
|
|
@@ -928,8 +936,9 @@ class ActiveRecord::Base
|
|
928
936
|
associated_objects_by_class = {}
|
929
937
|
models.each { |model| find_associated_objects_for_import(associated_objects_by_class, model) }
|
930
938
|
|
931
|
-
# :on_duplicate_key_update
|
932
|
-
options.delete(:on_duplicate_key_update)
|
939
|
+
# :on_duplicate_key_update only supported for all fields
|
940
|
+
options.delete(:on_duplicate_key_update) unless options[:on_duplicate_key_update] == :all
|
941
|
+
# :returning not supported for associations
|
933
942
|
options.delete(:returning)
|
934
943
|
|
935
944
|
associated_objects_by_class.each_value do |associations|
|
@@ -961,8 +970,13 @@ class ActiveRecord::Base
|
|
961
970
|
changed_objects.each do |child|
|
962
971
|
child.public_send("#{association_reflection.foreign_key}=", model.id)
|
963
972
|
# For polymorphic associations
|
973
|
+
association_name = if model.class.respond_to?(:polymorphic_name)
|
974
|
+
model.class.polymorphic_name
|
975
|
+
else
|
976
|
+
model.class.base_class
|
977
|
+
end
|
964
978
|
association_reflection.type.try do |type|
|
965
|
-
child.public_send("#{type}=",
|
979
|
+
child.public_send("#{type}=", association_name)
|
966
980
|
end
|
967
981
|
end
|
968
982
|
associated_objects_by_class[model.class.name][association_reflection.name].concat changed_objects
|
@@ -1023,7 +1037,12 @@ class ActiveRecord::Base
|
|
1023
1037
|
end
|
1024
1038
|
|
1025
1039
|
# use tz as set in ActiveRecord::Base
|
1026
|
-
|
1040
|
+
default_timezone = if ActiveRecord.respond_to?(:default_timezone)
|
1041
|
+
ActiveRecord.default_timezone
|
1042
|
+
else
|
1043
|
+
ActiveRecord::Base.default_timezone
|
1044
|
+
end
|
1045
|
+
timestamp = default_timezone == :utc ? Time.now.utc : Time.now
|
1027
1046
|
|
1028
1047
|
[:create, :update].each do |action|
|
1029
1048
|
timestamp_columns[action].each do |column|
|
@@ -39,7 +39,7 @@ module ActiveRecord # :nodoc:
|
|
39
39
|
|
40
40
|
next unless matched_instance
|
41
41
|
|
42
|
-
instance.
|
42
|
+
instance.instance_variable_set :@association_cache, {}
|
43
43
|
instance.send :clear_aggregation_cache if instance.respond_to?(:clear_aggregation_cache, true)
|
44
44
|
instance.instance_variable_set :@attributes, matched_instance.instance_variable_get(:@attributes)
|
45
45
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
common: &common
|
2
2
|
username: root
|
3
|
-
password:
|
3
|
+
password: root
|
4
4
|
encoding: utf8
|
5
|
+
collation: utf8_general_ci
|
5
6
|
host: localhost
|
6
7
|
database: activerecord_import_test
|
7
8
|
|
@@ -37,6 +38,7 @@ oracle:
|
|
37
38
|
postgresql: &postgresql
|
38
39
|
<<: *common
|
39
40
|
username: postgres
|
41
|
+
password: postgres
|
40
42
|
adapter: postgresql
|
41
43
|
min_messages: warning
|
42
44
|
|
data/test/import_test.rb
CHANGED
@@ -169,7 +169,17 @@ describe "#import" do
|
|
169
169
|
assert_difference "Dictionary.count", +1 do
|
170
170
|
Dictionary.import dictionaries
|
171
171
|
end
|
172
|
-
assert_equal "Dictionary", Dictionary.
|
172
|
+
assert_equal "Dictionary", Dictionary.last.type
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should import arrays successfully" do
|
176
|
+
columns = [:author_name, :title]
|
177
|
+
values = [["Noah Webster", "Webster's Dictionary"]]
|
178
|
+
|
179
|
+
assert_difference "Dictionary.count", +1 do
|
180
|
+
Dictionary.import columns, values
|
181
|
+
end
|
182
|
+
assert_equal "Dictionary", Dictionary.last.type
|
173
183
|
end
|
174
184
|
end
|
175
185
|
|
@@ -545,7 +555,11 @@ describe "#import" do
|
|
545
555
|
context "when the timestamps columns are present" do
|
546
556
|
setup do
|
547
557
|
@existing_book = Book.create(title: "Fell", author_name: "Curry", publisher: "Bayer", created_at: 2.years.ago.utc, created_on: 2.years.ago.utc, updated_at: 2.years.ago.utc, updated_on: 2.years.ago.utc)
|
548
|
-
ActiveRecord
|
558
|
+
if ActiveRecord.respond_to?(:default_timezone)
|
559
|
+
ActiveRecord.default_timezone = :utc
|
560
|
+
else
|
561
|
+
ActiveRecord::Base.default_timezone = :utc
|
562
|
+
end
|
549
563
|
Timecop.freeze(time) do
|
550
564
|
assert_difference "Book.count", +2 do
|
551
565
|
Book.import %w(title author_name publisher created_at created_on updated_at updated_on), [["LDAP", "Big Bird", "Del Rey", nil, nil, nil, nil], [@existing_book.title, @existing_book.author_name, @existing_book.publisher, @existing_book.created_at, @existing_book.created_on, @existing_book.updated_at, @existing_book.updated_on]]
|
@@ -661,6 +675,14 @@ describe "#import" do
|
|
661
675
|
assert_equal [val1, val2], scope.map(&column).sort
|
662
676
|
end
|
663
677
|
|
678
|
+
context "for cards and decks" do
|
679
|
+
it "works when the polymorphic name is different than base class name" do
|
680
|
+
deck = Deck.create(id: 1, name: 'test')
|
681
|
+
deck.cards.import [:id, :deck_type], [[1, 'PlayingCard']]
|
682
|
+
assert_equal deck.cards.first.deck_type, "PlayingCard"
|
683
|
+
end
|
684
|
+
end
|
685
|
+
|
664
686
|
it "works importing array of hashes" do
|
665
687
|
scope.import [{ column => val1 }, { column => val2 }]
|
666
688
|
|
data/test/models/card.rb
ADDED
data/test/models/deck.rb
ADDED
@@ -52,6 +52,20 @@ ActiveRecord::Schema.define do
|
|
52
52
|
t.string :name
|
53
53
|
end
|
54
54
|
|
55
|
+
create_table :cards, force: :cascade do |t|
|
56
|
+
t.string :name
|
57
|
+
t.string :deck_type
|
58
|
+
t.integer :deck_id
|
59
|
+
end
|
60
|
+
|
61
|
+
create_table :decks, force: :cascade do |t|
|
62
|
+
t.string :name
|
63
|
+
end
|
64
|
+
|
65
|
+
create_table :playing_cards, force: :cascade do |t|
|
66
|
+
t.string :name
|
67
|
+
end
|
68
|
+
|
55
69
|
create_table :books, force: :cascade do |t|
|
56
70
|
t.string :title, null: false
|
57
71
|
t.string :publisher, null: false, default: 'Default Publisher'
|
@@ -191,4 +205,15 @@ ActiveRecord::Schema.define do
|
|
191
205
|
);
|
192
206
|
).split.join(' ').strip
|
193
207
|
end
|
208
|
+
|
209
|
+
create_table :customers, force: :cascade do |t|
|
210
|
+
t.integer :account_id
|
211
|
+
t.string :name
|
212
|
+
end
|
213
|
+
|
214
|
+
create_table :orders, force: :cascade do |t|
|
215
|
+
t.integer :account_id
|
216
|
+
t.integer :customer_id
|
217
|
+
t.integer :amount
|
218
|
+
end
|
194
219
|
end
|
@@ -281,7 +281,7 @@ def should_support_postgresql_import_functionality
|
|
281
281
|
end
|
282
282
|
|
283
283
|
describe "with binary field" do
|
284
|
-
let(:binary_value) { "\xE0'c\xB2\xB0\xB3Bh\\\xC2M\xB1m\\I\xC4r".force_encoding('ASCII-8BIT') }
|
284
|
+
let(:binary_value) { "\xE0'c\xB2\xB0\xB3Bh\\\xC2M\xB1m\\I\xC4r".dup.force_encoding('ASCII-8BIT') }
|
285
285
|
it "imports the correct values for binary fields" do
|
286
286
|
alarms = [Alarm.new(device_id: 1, alarm_type: 1, status: 1, secret_key: binary_value)]
|
287
287
|
assert_difference "Alarm.count", +1 do
|
@@ -290,6 +290,30 @@ def should_support_postgresql_import_functionality
|
|
290
290
|
assert_equal(binary_value, Alarm.first.secret_key)
|
291
291
|
end
|
292
292
|
end
|
293
|
+
|
294
|
+
unless ENV["SKIP_COMPOSITE_PK"]
|
295
|
+
describe "with composite foreign keys" do
|
296
|
+
let(:account_id) { 555 }
|
297
|
+
let(:customer) { Customer.new(account_id: account_id, name: "foo") }
|
298
|
+
let(:order) { Order.new(account_id: account_id, amount: 100, customer: customer) }
|
299
|
+
|
300
|
+
it "imports and correctly maps foreign keys" do
|
301
|
+
assert_difference "Customer.count", +1 do
|
302
|
+
Customer.import [customer]
|
303
|
+
end
|
304
|
+
|
305
|
+
assert_difference "Order.count", +1 do
|
306
|
+
Order.import [order]
|
307
|
+
end
|
308
|
+
|
309
|
+
db_customer = Customer.last
|
310
|
+
db_order = Order.last
|
311
|
+
|
312
|
+
assert_equal db_customer.orders.last, db_order
|
313
|
+
assert_not_equal db_order.customer_id, nil
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
293
317
|
end
|
294
318
|
|
295
319
|
def should_support_postgresql_upsert_functionality
|
@@ -176,7 +176,7 @@ def should_support_recursive_import
|
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
-
# If adapter supports on_duplicate_key_update, it is only applied to top level models so that SQL with invalid
|
179
|
+
# If adapter supports on_duplicate_key_update and specific columns are specified, it is only applied to top level models so that SQL with invalid
|
180
180
|
# columns, keys, etc isn't generated for child associations when doing recursive import
|
181
181
|
if ActiveRecord::Base.connection.supports_on_duplicate_key_update?
|
182
182
|
describe "on_duplicate_key_update" do
|
@@ -190,6 +190,26 @@ def should_support_recursive_import
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
193
|
+
|
194
|
+
context "when :all fields are updated" do
|
195
|
+
setup do
|
196
|
+
Topic.import new_topics, recursive: true
|
197
|
+
end
|
198
|
+
|
199
|
+
it "updates associated objects" do
|
200
|
+
new_author_name = 'Richard Bachman'
|
201
|
+
topic = new_topics.first
|
202
|
+
topic.books.each do |book|
|
203
|
+
book.author_name = new_author_name
|
204
|
+
end
|
205
|
+
assert_nothing_raised do
|
206
|
+
Topic.import new_topics, recursive: true, on_duplicate_key_update: :all
|
207
|
+
end
|
208
|
+
Topic.find(topic.id).books.each do |book|
|
209
|
+
assert_equal new_author_name, book.author_name
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
193
213
|
end
|
194
214
|
end
|
195
215
|
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pathname'
|
2
|
+
require 'rake'
|
2
3
|
test_dir = Pathname.new File.dirname(__FILE__)
|
3
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
@@ -50,14 +51,22 @@ ActiveRecord::Base.logger = Logger.new("log/test.log")
|
|
50
51
|
ActiveRecord::Base.logger.level = Logger::DEBUG
|
51
52
|
|
52
53
|
if ENV['AR_VERSION'].to_f >= 6.0
|
53
|
-
yaml_config =
|
54
|
+
yaml_config = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.2.1')
|
55
|
+
YAML.safe_load_file(test_dir.join("database.yml"), aliases: true)[adapter]
|
56
|
+
else
|
57
|
+
YAML.load_file(test_dir.join("database.yml"))[adapter]
|
58
|
+
end
|
54
59
|
config = ActiveRecord::DatabaseConfigurations::HashConfig.new("test", adapter, yaml_config)
|
55
60
|
ActiveRecord::Base.configurations.configurations << config
|
56
61
|
else
|
57
62
|
ActiveRecord::Base.configurations["test"] = YAML.load_file(test_dir.join("database.yml"))[adapter]
|
58
63
|
end
|
59
64
|
|
60
|
-
ActiveRecord
|
65
|
+
if ActiveRecord.respond_to?(:default_timezone)
|
66
|
+
ActiveRecord.default_timezone = :utc
|
67
|
+
else
|
68
|
+
ActiveRecord::Base.default_timezone = :utc
|
69
|
+
end
|
61
70
|
|
62
71
|
require "activerecord-import"
|
63
72
|
ActiveRecord::Base.establish_connection :test
|
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.4.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: 2022-03-31 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,10 +45,10 @@ 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
54
|
- Gemfile
|
@@ -68,15 +68,13 @@ files:
|
|
68
68
|
- benchmarks/models/test_memory.rb
|
69
69
|
- benchmarks/models/test_myisam.rb
|
70
70
|
- benchmarks/schema/mysql2_schema.rb
|
71
|
-
- gemfiles/3.2.gemfile
|
72
|
-
- gemfiles/4.0.gemfile
|
73
|
-
- gemfiles/4.1.gemfile
|
74
71
|
- gemfiles/4.2.gemfile
|
75
72
|
- gemfiles/5.0.gemfile
|
76
73
|
- gemfiles/5.1.gemfile
|
77
74
|
- gemfiles/5.2.gemfile
|
78
75
|
- gemfiles/6.0.gemfile
|
79
76
|
- gemfiles/6.1.gemfile
|
77
|
+
- gemfiles/7.0.gemfile
|
80
78
|
- lib/activerecord-import.rb
|
81
79
|
- lib/activerecord-import/active_record/adapters/abstract_adapter.rb
|
82
80
|
- lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb
|
@@ -114,6 +112,7 @@ files:
|
|
114
112
|
- test/adapters/spatialite.rb
|
115
113
|
- test/adapters/sqlite3.rb
|
116
114
|
- test/database.yml.sample
|
115
|
+
- test/github/database.yml
|
117
116
|
- test/import_test.rb
|
118
117
|
- test/jdbcmysql/import_test.rb
|
119
118
|
- test/jdbcpostgresql/import_test.rb
|
@@ -125,11 +124,16 @@ files:
|
|
125
124
|
- test/models/bike_maker.rb
|
126
125
|
- test/models/book.rb
|
127
126
|
- test/models/car.rb
|
127
|
+
- test/models/card.rb
|
128
128
|
- test/models/chapter.rb
|
129
|
+
- test/models/customer.rb
|
130
|
+
- test/models/deck.rb
|
129
131
|
- test/models/dictionary.rb
|
130
132
|
- test/models/discount.rb
|
131
133
|
- test/models/end_note.rb
|
132
134
|
- test/models/group.rb
|
135
|
+
- test/models/order.rb
|
136
|
+
- test/models/playing_card.rb
|
133
137
|
- test/models/promotion.rb
|
134
138
|
- test/models/question.rb
|
135
139
|
- test/models/rule.rb
|
@@ -164,14 +168,13 @@ files:
|
|
164
168
|
- test/support/sqlite3/import_examples.rb
|
165
169
|
- test/synchronize_test.rb
|
166
170
|
- test/test_helper.rb
|
167
|
-
- test/travis/database.yml
|
168
171
|
- test/value_sets_bytes_parser_test.rb
|
169
172
|
- test/value_sets_records_parser_test.rb
|
170
173
|
homepage: https://github.com/zdennis/activerecord-import
|
171
174
|
licenses:
|
172
175
|
- MIT
|
173
176
|
metadata: {}
|
174
|
-
post_install_message:
|
177
|
+
post_install_message:
|
175
178
|
rdoc_options: []
|
176
179
|
require_paths:
|
177
180
|
- lib
|
@@ -179,15 +182,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
182
|
requirements:
|
180
183
|
- - ">="
|
181
184
|
- !ruby/object:Gem::Version
|
182
|
-
version: 2.
|
185
|
+
version: 2.4.0
|
183
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
187
|
requirements:
|
185
188
|
- - ">="
|
186
189
|
- !ruby/object:Gem::Version
|
187
190
|
version: '0'
|
188
191
|
requirements: []
|
189
|
-
rubygems_version: 3.0.
|
190
|
-
signing_key:
|
192
|
+
rubygems_version: 3.0.3
|
193
|
+
signing_key:
|
191
194
|
specification_version: 4
|
192
195
|
summary: Bulk insert extension for ActiveRecord
|
193
196
|
test_files:
|
@@ -205,6 +208,7 @@ test_files:
|
|
205
208
|
- test/adapters/spatialite.rb
|
206
209
|
- test/adapters/sqlite3.rb
|
207
210
|
- test/database.yml.sample
|
211
|
+
- test/github/database.yml
|
208
212
|
- test/import_test.rb
|
209
213
|
- test/jdbcmysql/import_test.rb
|
210
214
|
- test/jdbcpostgresql/import_test.rb
|
@@ -216,11 +220,16 @@ test_files:
|
|
216
220
|
- test/models/bike_maker.rb
|
217
221
|
- test/models/book.rb
|
218
222
|
- test/models/car.rb
|
223
|
+
- test/models/card.rb
|
219
224
|
- test/models/chapter.rb
|
225
|
+
- test/models/customer.rb
|
226
|
+
- test/models/deck.rb
|
220
227
|
- test/models/dictionary.rb
|
221
228
|
- test/models/discount.rb
|
222
229
|
- test/models/end_note.rb
|
223
230
|
- test/models/group.rb
|
231
|
+
- test/models/order.rb
|
232
|
+
- test/models/playing_card.rb
|
224
233
|
- test/models/promotion.rb
|
225
234
|
- test/models/question.rb
|
226
235
|
- test/models/rule.rb
|
@@ -255,6 +264,5 @@ test_files:
|
|
255
264
|
- test/support/sqlite3/import_examples.rb
|
256
265
|
- test/synchronize_test.rb
|
257
266
|
- test/test_helper.rb
|
258
|
-
- test/travis/database.yml
|
259
267
|
- test/value_sets_bytes_parser_test.rb
|
260
268
|
- test/value_sets_records_parser_test.rb
|
data/.travis.yml
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
rvm:
|
4
|
-
- 2.5.8
|
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=5.1
|
12
|
-
- AR_VERSION=5.2
|
13
|
-
- AR_VERSION=6.0
|
14
|
-
- AR_VERSION=6.1
|
15
|
-
|
16
|
-
matrix:
|
17
|
-
include:
|
18
|
-
- rvm: 2.3.8
|
19
|
-
env: AR_VERSION=3.2
|
20
|
-
- rvm: 2.3.8
|
21
|
-
env: AR_VERSION=4.0
|
22
|
-
- rvm: 2.3.8
|
23
|
-
env: AR_VERSION=4.1
|
24
|
-
- rvm: 2.3.8
|
25
|
-
env: AR_VERSION=4.2
|
26
|
-
- rvm: 2.3.8
|
27
|
-
env: AR_VERSION=5.0
|
28
|
-
|
29
|
-
fast_finish: true
|
30
|
-
|
31
|
-
addons:
|
32
|
-
postgresql: "10"
|
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-10-postgis-2.4
|
42
|
-
|
43
|
-
before_install:
|
44
|
-
- sudo apt-get update
|
45
|
-
- gem update --system
|
46
|
-
- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
|
47
|
-
- sudo mysql_upgrade
|
48
|
-
- sudo service mysql restart
|
49
|
-
|
50
|
-
before_script:
|
51
|
-
- mysql -e 'create database activerecord_import_test;'
|
52
|
-
- psql -c 'create database activerecord_import_test;' -U postgres
|
53
|
-
- psql activerecord_import_test -c 'create extension if not exists hstore;' -U postgres
|
54
|
-
- psql -c 'create extension if not exists postgis;' -U postgres
|
55
|
-
- psql -c 'create extension if not exists "uuid-ossp";' -U postgres
|
56
|
-
- cp test/travis/database.yml test/database.yml
|
57
|
-
|
58
|
-
script:
|
59
|
-
- bundle exec rake test:mysql2
|
60
|
-
- bundle exec rake test:mysql2_makara
|
61
|
-
- bundle exec rake test:mysql2spatial
|
62
|
-
- bundle exec rake test:postgis
|
63
|
-
- bundle exec rake test:postgresql
|
64
|
-
- bundle exec rake test:postgresql_makara
|
65
|
-
- bundle exec rake test:seamless_database_pool
|
66
|
-
- bundle exec rake test:spatialite
|
67
|
-
- bundle exec rake test:sqlite3
|
68
|
-
- bundle exec rubocop
|
69
|
-
|
70
|
-
dist: xenial
|
71
|
-
|
72
|
-
services:
|
73
|
-
- mysql
|
74
|
-
- postgresql
|
75
|
-
|
76
|
-
sudo: required
|
data/gemfiles/3.2.gemfile
DELETED
data/gemfiles/4.0.gemfile
DELETED
data/gemfiles/4.1.gemfile
DELETED