activerecord-import 1.0.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yaml +159 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +76 -7
- data/.rubocop_todo.yml +10 -16
- data/Brewfile +3 -1
- data/CHANGELOG.md +143 -3
- data/Dockerfile +23 -0
- data/Gemfile +28 -24
- data/LICENSE +21 -56
- data/README.markdown +83 -27
- data/Rakefile +3 -0
- data/activerecord-import.gemspec +10 -5
- data/benchmarks/benchmark.rb +10 -6
- data/benchmarks/lib/base.rb +10 -5
- data/benchmarks/lib/cli_parser.rb +10 -6
- 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/5.2.gemfile +2 -0
- data/gemfiles/6.0.gemfile +3 -0
- data/gemfiles/6.1.gemfile +4 -1
- data/gemfiles/7.0.gemfile +4 -0
- data/gemfiles/7.1.gemfile +3 -0
- data/gemfiles/7.2.gemfile +3 -0
- data/gemfiles/8.0.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 +9 -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 +30 -21
- data/lib/activerecord-import/adapters/postgresql_adapter.rb +68 -48
- data/lib/activerecord-import/adapters/sqlite3_adapter.rb +37 -30
- data/lib/activerecord-import/adapters/trilogy_adapter.rb +7 -0
- data/lib/activerecord-import/base.rb +3 -1
- data/lib/activerecord-import/import.rb +160 -58
- data/lib/activerecord-import/synchronize.rb +3 -1
- 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 +9 -3
- data/test/import_test.rb +108 -41
- 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 +9 -0
- data/test/models/bike_maker.rb +3 -0
- data/test/models/book.rb +12 -3
- 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 +12 -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 +8 -0
- data/test/models/user.rb +2 -0
- data/test/models/user_token.rb +2 -0
- data/test/models/vendor.rb +2 -0
- data/test/models/widget.rb +12 -3
- 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 +38 -4
- data/test/schema/sqlite3_schema.rb +2 -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 +3 -5
- data/test/support/assertions.rb +2 -0
- data/test/support/factories.rb +2 -0
- data/test/support/generate.rb +4 -2
- data/test/support/mysql/import_examples.rb +7 -8
- data/test/support/postgresql/import_examples.rb +121 -53
- data/test/support/shared_examples/on_duplicate_key_ignore.rb +2 -0
- data/test/support/shared_examples/on_duplicate_key_update.rb +69 -10
- data/test/support/shared_examples/recursive_import.rb +137 -1
- data/test/support/sqlite3/import_examples.rb +2 -1
- data/test/synchronize_test.rb +2 -0
- data/test/test_helper.rb +38 -24
- 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 -22
- data/.travis.yml +0 -74
- data/gemfiles/3.2.gemfile +0 -2
- data/gemfiles/4.0.gemfile +0 -2
- data/gemfiles/4.1.gemfile +0 -2
- data/gemfiles/4.2.gemfile +0 -2
- data/gemfiles/5.0.gemfile +0 -2
- data/gemfiles/5.1.gemfile +0 -2
- data/lib/activerecord-import/mysql2.rb +0 -7
- data/lib/activerecord-import/postgresql.rb +0 -7
- data/lib/activerecord-import/sqlite3.rb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f55c9faf85e948fbeb480ebca5baeca11b2275a626bc6ba7517e9d3e8c37e9e7
|
|
4
|
+
data.tar.gz: 80b267b08ef3a10bb91b029401e8fb6b49fdfcadeeb29a2e5e18fd6c8f529192
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f838da07331afe7827ad7d4f323ebf3f2191decd59a82359393f20eee866345258abb979875dd1c9b853533099797cdf7599ded20ca4e07997f8bce491f4c03e
|
|
7
|
+
data.tar.gz: 5a257bacb43492f25a65ecc382fe8ad126c4dac474eae7ee2beb3ba92c2cb95e64070a40cd20c48e47f46b51e64b69c2addd76a15fed75863df2ecb4a0fbdb70
|
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
mysql:
|
|
20
|
+
image: mysql:5.7
|
|
21
|
+
ports:
|
|
22
|
+
- 3306:3306
|
|
23
|
+
env:
|
|
24
|
+
MYSQL_HOST: 127.0.0.1
|
|
25
|
+
MYSQL_ROOT_PASSWORD: root
|
|
26
|
+
MYSQL_USER: github
|
|
27
|
+
MYSQL_PASSWORD: github
|
|
28
|
+
MYSQL_DATABASE: activerecord_import_test
|
|
29
|
+
options: >-
|
|
30
|
+
--health-cmd "mysqladmin ping -h localhost"
|
|
31
|
+
--health-interval 10s
|
|
32
|
+
--health-timeout 5s
|
|
33
|
+
--health-retries 5
|
|
34
|
+
strategy:
|
|
35
|
+
fail-fast: false
|
|
36
|
+
matrix:
|
|
37
|
+
ruby:
|
|
38
|
+
- 3.3
|
|
39
|
+
env:
|
|
40
|
+
- AR_VERSION: '8.0'
|
|
41
|
+
RUBYOPT: --enable-frozen-string-literal
|
|
42
|
+
- AR_VERSION: '7.2'
|
|
43
|
+
RUBYOPT: --enable-frozen-string-literal
|
|
44
|
+
- AR_VERSION: '7.1'
|
|
45
|
+
RUBYOPT: --enable-frozen-string-literal
|
|
46
|
+
- AR_VERSION: '7.0'
|
|
47
|
+
RUBYOPT: --enable-frozen-string-literal
|
|
48
|
+
- AR_VERSION: 6.1
|
|
49
|
+
RUBYOPT: --enable-frozen-string-literal
|
|
50
|
+
include:
|
|
51
|
+
- ruby: 3.2
|
|
52
|
+
env:
|
|
53
|
+
AR_VERSION: '8.0'
|
|
54
|
+
- ruby: 3.2
|
|
55
|
+
env:
|
|
56
|
+
AR_VERSION: '7.2'
|
|
57
|
+
- ruby: 3.2
|
|
58
|
+
env:
|
|
59
|
+
AR_VERSION: '7.1'
|
|
60
|
+
- ruby: 3.2
|
|
61
|
+
env:
|
|
62
|
+
AR_VERSION: '7.0'
|
|
63
|
+
- ruby: 3.2
|
|
64
|
+
env:
|
|
65
|
+
AR_VERSION: 6.1
|
|
66
|
+
- ruby: 3.1
|
|
67
|
+
env:
|
|
68
|
+
AR_VERSION: '7.1'
|
|
69
|
+
- ruby: 3.1
|
|
70
|
+
env:
|
|
71
|
+
AR_VERSION: '7.0'
|
|
72
|
+
- ruby: 3.1
|
|
73
|
+
env:
|
|
74
|
+
AR_VERSION: 6.1
|
|
75
|
+
- ruby: '3.0'
|
|
76
|
+
env:
|
|
77
|
+
AR_VERSION: '7.0'
|
|
78
|
+
- ruby: '3.0'
|
|
79
|
+
env:
|
|
80
|
+
AR_VERSION: 6.1
|
|
81
|
+
- ruby: jruby-9.4.8.0
|
|
82
|
+
env:
|
|
83
|
+
AR_VERSION: '7.0'
|
|
84
|
+
- ruby: 2.7
|
|
85
|
+
env:
|
|
86
|
+
AR_VERSION: '7.0'
|
|
87
|
+
- ruby: 2.7
|
|
88
|
+
env:
|
|
89
|
+
AR_VERSION: 6.1
|
|
90
|
+
- ruby: 2.7
|
|
91
|
+
env:
|
|
92
|
+
AR_VERSION: '6.0'
|
|
93
|
+
- ruby: jruby-9.3.15.0
|
|
94
|
+
env:
|
|
95
|
+
AR_VERSION: '6.1'
|
|
96
|
+
- ruby: 2.6
|
|
97
|
+
env:
|
|
98
|
+
AR_VERSION: 5.2
|
|
99
|
+
runs-on: ubuntu-latest
|
|
100
|
+
env:
|
|
101
|
+
AR_VERSION: ${{ matrix.env.AR_VERSION }}
|
|
102
|
+
DB_DATABASE: activerecord_import_test
|
|
103
|
+
steps:
|
|
104
|
+
- uses: actions/checkout@v4
|
|
105
|
+
- name: Install SQLite3 Development Library
|
|
106
|
+
run: |
|
|
107
|
+
sudo apt-get update
|
|
108
|
+
sudo apt-get install libsqlite3-dev
|
|
109
|
+
- uses: ruby/setup-ruby@v1
|
|
110
|
+
with:
|
|
111
|
+
ruby-version: ${{ matrix.ruby }}
|
|
112
|
+
bundler-cache: true
|
|
113
|
+
rubygems: latest
|
|
114
|
+
- name: Set up databases
|
|
115
|
+
run: |
|
|
116
|
+
psql -h localhost -U postgres -c 'create database ${{ env.DB_DATABASE }};'
|
|
117
|
+
psql -h localhost -U postgres -d ${{ env.DB_DATABASE }} -c 'create extension if not exists hstore;'
|
|
118
|
+
psql -h localhost -U postgres -c 'create extension if not exists postgis;'
|
|
119
|
+
psql -h localhost -U postgres -c 'create extension if not exists "uuid-ossp";'
|
|
120
|
+
cp test/github/database.yml test/database.yml
|
|
121
|
+
env:
|
|
122
|
+
PGPASSWORD: postgres
|
|
123
|
+
- name: Run tests with mysql2
|
|
124
|
+
run: |
|
|
125
|
+
bundle exec rake test:mysql2
|
|
126
|
+
bundle exec rake test:mysql2_makara
|
|
127
|
+
bundle exec rake test:mysql2spatial
|
|
128
|
+
- name: Run tests with postgresql
|
|
129
|
+
run: |
|
|
130
|
+
bundle exec rake test:postgis
|
|
131
|
+
bundle exec rake test:postgresql
|
|
132
|
+
bundle exec rake test:postgresql_makara
|
|
133
|
+
- name: Run tests with seamless_database_pool
|
|
134
|
+
run: |
|
|
135
|
+
bundle exec rake test:seamless_database_pool
|
|
136
|
+
if: ${{ matrix.ruby < '3.0' }}
|
|
137
|
+
- name: Run tests with sqlite
|
|
138
|
+
run: |
|
|
139
|
+
bundle exec rake test:spatialite
|
|
140
|
+
bundle exec rake test:sqlite3
|
|
141
|
+
- name: Run trilogy tests
|
|
142
|
+
if: ${{ matrix.env.AR_VERSION >= '7.0' && !startsWith(matrix.ruby, 'jruby') }}
|
|
143
|
+
run: bundle exec rake test:trilogy
|
|
144
|
+
lint:
|
|
145
|
+
runs-on: ubuntu-latest
|
|
146
|
+
env:
|
|
147
|
+
AR_VERSION: '7.0'
|
|
148
|
+
steps:
|
|
149
|
+
- uses: actions/checkout@v4
|
|
150
|
+
- name: Install SQLite3 Development Library
|
|
151
|
+
run: |
|
|
152
|
+
sudo apt-get update
|
|
153
|
+
sudo apt-get install libsqlite3-dev
|
|
154
|
+
- uses: ruby/setup-ruby@v1
|
|
155
|
+
with:
|
|
156
|
+
ruby-version: 3.0
|
|
157
|
+
bundler-cache: true
|
|
158
|
+
- name: Run Rubocop
|
|
159
|
+
run: bundle exec rubocop
|
data/.gitignore
CHANGED
|
@@ -13,17 +13,22 @@ tmtags
|
|
|
13
13
|
## VIM
|
|
14
14
|
*.swp
|
|
15
15
|
|
|
16
|
+
## Idea
|
|
17
|
+
.idea
|
|
18
|
+
|
|
16
19
|
## PROJECT::GENERAL
|
|
17
20
|
coverage
|
|
18
21
|
rdoc
|
|
19
22
|
pkg
|
|
20
23
|
*.gem
|
|
21
24
|
*.lock
|
|
25
|
+
.byebug_history
|
|
22
26
|
|
|
23
27
|
## PROJECT::SPECIFIC
|
|
24
28
|
log/*.log
|
|
25
29
|
test.db
|
|
26
30
|
test/database.yml
|
|
31
|
+
benchmarks/log/
|
|
27
32
|
|
|
28
33
|
.ruby-*
|
|
29
34
|
.bundle/
|
data/.rubocop.yml
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
AllCops:
|
|
4
|
+
TargetRubyVersion: 3.0.x
|
|
5
5
|
|
|
6
6
|
Metrics/AbcSize:
|
|
7
7
|
Enabled: false
|
|
8
8
|
|
|
9
|
+
Metrics/BlockLength:
|
|
10
|
+
Enabled: false
|
|
11
|
+
|
|
9
12
|
Metrics/ClassLength:
|
|
10
13
|
Enabled: false
|
|
11
14
|
|
|
@@ -24,8 +27,8 @@ Metrics/ModuleLength:
|
|
|
24
27
|
Metrics/PerceivedComplexity:
|
|
25
28
|
Enabled: false
|
|
26
29
|
|
|
27
|
-
Style/
|
|
28
|
-
|
|
30
|
+
Style/CommentedKeyword:
|
|
31
|
+
Enabled: false
|
|
29
32
|
|
|
30
33
|
Style/ClassAndModuleChildren:
|
|
31
34
|
Enabled: false
|
|
@@ -33,10 +36,25 @@ Style/ClassAndModuleChildren:
|
|
|
33
36
|
Style/Documentation:
|
|
34
37
|
Enabled: false
|
|
35
38
|
|
|
36
|
-
Style/
|
|
39
|
+
Style/EvalWithLocation:
|
|
40
|
+
Enabled: false
|
|
41
|
+
|
|
42
|
+
Style/ExpandPathArguments:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
Style/GuardClause:
|
|
46
|
+
Enabled: false
|
|
47
|
+
|
|
48
|
+
Style/IfUnlessModifier:
|
|
49
|
+
Enabled: false
|
|
50
|
+
|
|
51
|
+
Style/NumericPredicate:
|
|
37
52
|
Enabled: false
|
|
38
53
|
|
|
39
|
-
Style/
|
|
54
|
+
Style/PercentLiteralDelimiters:
|
|
55
|
+
Enabled: false
|
|
56
|
+
|
|
57
|
+
Style/RedundantBegin:
|
|
40
58
|
Enabled: false
|
|
41
59
|
|
|
42
60
|
Style/SpecialGlobalVars:
|
|
@@ -45,5 +63,56 @@ Style/SpecialGlobalVars:
|
|
|
45
63
|
Style/StringLiterals:
|
|
46
64
|
Enabled: false
|
|
47
65
|
|
|
48
|
-
Style/
|
|
66
|
+
Style/SymbolArray:
|
|
67
|
+
Enabled: false
|
|
68
|
+
|
|
69
|
+
Style/TrailingCommaInArrayLiteral:
|
|
70
|
+
Enabled: false
|
|
71
|
+
|
|
72
|
+
Layout/ArgumentAlignment:
|
|
73
|
+
Enabled: false
|
|
74
|
+
|
|
75
|
+
Layout/ParameterAlignment:
|
|
76
|
+
EnforcedStyle: with_fixed_indentation
|
|
77
|
+
|
|
78
|
+
Layout/EndAlignment:
|
|
79
|
+
EnforcedStyleAlignWith: variable
|
|
80
|
+
|
|
81
|
+
Layout/ElseAlignment:
|
|
82
|
+
Enabled: false
|
|
83
|
+
|
|
84
|
+
Layout/EmptyLineAfterGuardClause:
|
|
85
|
+
Enabled: false
|
|
86
|
+
|
|
87
|
+
Layout/HeredocIndentation:
|
|
88
|
+
Enabled: false
|
|
89
|
+
|
|
90
|
+
Layout/SpaceInsideParens:
|
|
91
|
+
Enabled: false
|
|
92
|
+
|
|
93
|
+
Layout/SpaceInsidePercentLiteralDelimiters:
|
|
94
|
+
Enabled: false
|
|
95
|
+
|
|
96
|
+
Lint/ErbNewArguments:
|
|
97
|
+
Enabled: false
|
|
98
|
+
|
|
99
|
+
Lint/MissingCopEnableDirective:
|
|
100
|
+
Enabled: false
|
|
101
|
+
|
|
102
|
+
Lint/PercentStringArray:
|
|
103
|
+
Enabled: false
|
|
104
|
+
|
|
105
|
+
Naming/HeredocDelimiterNaming:
|
|
106
|
+
Enabled: false
|
|
107
|
+
|
|
108
|
+
Naming/MethodParameterName:
|
|
109
|
+
Enabled: false
|
|
110
|
+
|
|
111
|
+
Security/YAMLLoad:
|
|
112
|
+
Enabled: false
|
|
113
|
+
|
|
114
|
+
Gemspec/RequiredRubyVersion:
|
|
115
|
+
Enabled: false
|
|
116
|
+
|
|
117
|
+
Bundler/OrderedGems:
|
|
49
118
|
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2023-02-15 00:58:14 UTC using RuboCop version 1.45.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count: 2
|
|
10
|
-
Lint/HandleExceptions:
|
|
11
|
-
Exclude:
|
|
12
|
-
- 'lib/activerecord-import/base.rb'
|
|
13
|
-
- 'test/import_test.rb'
|
|
14
|
-
|
|
15
9
|
# Offense count: 2
|
|
16
10
|
Lint/RescueException:
|
|
17
11
|
Exclude:
|
|
18
12
|
- 'benchmarks/lib/cli_parser.rb'
|
|
19
13
|
- 'test/import_test.rb'
|
|
20
14
|
|
|
21
|
-
# Offense count:
|
|
22
|
-
#
|
|
23
|
-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
|
15
|
+
# Offense count: 3
|
|
16
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
17
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
|
24
18
|
Lint/UnusedMethodArgument:
|
|
25
19
|
Exclude:
|
|
26
20
|
- 'lib/activerecord-import/adapters/postgresql_adapter.rb'
|
|
27
21
|
- 'lib/activerecord-import/import.rb'
|
|
28
22
|
|
|
29
23
|
# Offense count: 2
|
|
30
|
-
|
|
31
|
-
# Configuration parameters: Keywords.
|
|
32
|
-
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
|
|
33
|
-
Style/CommentAnnotation:
|
|
24
|
+
Style/CombinableLoops:
|
|
34
25
|
Exclude:
|
|
35
|
-
- '
|
|
36
|
-
|
|
26
|
+
- 'test/support/shared_examples/recursive_import.rb'
|
|
27
|
+
|
|
28
|
+
Naming/FileName:
|
|
29
|
+
Exclude:
|
|
30
|
+
- 'lib/activerecord-import.rb'
|
data/Brewfile
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,143 @@
|
|
|
1
|
+
## Changes in 2.0.0
|
|
2
|
+
|
|
3
|
+
### Breaking Changes
|
|
4
|
+
|
|
5
|
+
* Fix `recursive_on_duplicate_key_update` doesn't work with non-standard
|
|
6
|
+
association name. Thanks to @jacob-carlborg-apoex via \#852. The documentation for the
|
|
7
|
+
`:recursive_on_duplicate_key_update` option specifies that the hash key is
|
|
8
|
+
the association name. But previously the name of associated table was used to
|
|
9
|
+
look up the options. Now the behavior matches the documentation and the name
|
|
10
|
+
of the association is used instead. This only affects associations that uses
|
|
11
|
+
a name that doesn't follow the ActiveRecord naming conventions of
|
|
12
|
+
associations and class names, i.e. when the `class_name:` option is used on
|
|
13
|
+
an association.
|
|
14
|
+
|
|
15
|
+
## Changes in 1.8.1
|
|
16
|
+
|
|
17
|
+
### Fixes
|
|
18
|
+
|
|
19
|
+
* Further update for ActiveRecord 7.2 compatibility when running validations. Thanks to @denisahearn via \##847.
|
|
20
|
+
|
|
21
|
+
## Changes in 1.8.0
|
|
22
|
+
|
|
23
|
+
### New Features
|
|
24
|
+
|
|
25
|
+
* Add support for ActiveRecord 7.2 via \##845.
|
|
26
|
+
|
|
27
|
+
## Changes in 1.7.0
|
|
28
|
+
|
|
29
|
+
### New Features
|
|
30
|
+
|
|
31
|
+
* Add support for ActiveRecord 7.1 composite primary keys. Thanks to @fragkakis via \##837.
|
|
32
|
+
* Add support for upserting associations when doing recursive imports. Thanks to @ramblex via \##778.
|
|
33
|
+
|
|
34
|
+
## Changes in 1.6.0
|
|
35
|
+
|
|
36
|
+
### New Features
|
|
37
|
+
|
|
38
|
+
* Add trilogy adapter support. Thanks to @zmariscal via \##825.
|
|
39
|
+
|
|
40
|
+
### Fixes
|
|
41
|
+
|
|
42
|
+
* Use the locking_enabled? method provided by activerecord to decide whether the lock field should be updated. Thanks to @dombesz via \##822.
|
|
43
|
+
|
|
44
|
+
## Changes in 1.5.1
|
|
45
|
+
|
|
46
|
+
### Fixes
|
|
47
|
+
|
|
48
|
+
* Stop memoizing schema_columns_hash so dynamic schema changes are picked up. Thanks to @koshigoe via \##812.
|
|
49
|
+
|
|
50
|
+
## Changes in 1.5.0
|
|
51
|
+
|
|
52
|
+
### New Features
|
|
53
|
+
|
|
54
|
+
* Add Rails 7.1 support. Thanks to @gucki via \##807.
|
|
55
|
+
* Add support for alias attributes. Thanks to @leonidkroka via \##799.
|
|
56
|
+
|
|
57
|
+
### Fixes
|
|
58
|
+
|
|
59
|
+
* Support for multi-byte column names when splitting queries. Thanks to @TakuyaKurimoto via \##801.
|
|
60
|
+
* Fix issue with track_validation_failures when import models. Thanks to @OtaYohihiro via \##798.
|
|
61
|
+
|
|
62
|
+
## Changes in 1.4.1
|
|
63
|
+
|
|
64
|
+
### Fixes
|
|
65
|
+
|
|
66
|
+
* Fix importing models that have required belongs_to associations and use composite primary keys. Thanks to @thoughtbot-summer via \##783.
|
|
67
|
+
|
|
68
|
+
## Changes in 1.4.0
|
|
69
|
+
|
|
70
|
+
### New Features
|
|
71
|
+
|
|
72
|
+
* Enable compatibility with frozen string literals. Thanks to @desheikh via \##760.
|
|
73
|
+
|
|
74
|
+
## Changes in 1.3.0
|
|
75
|
+
|
|
76
|
+
### Fixes
|
|
77
|
+
|
|
78
|
+
* Ensure correct timestamp values are returned for models after insert. Thanks to @kos1kov via \##756.
|
|
79
|
+
* Restore database_version method to public scope. Thanks to @beauraF via \##753.
|
|
80
|
+
|
|
81
|
+
### New Features
|
|
82
|
+
|
|
83
|
+
* Add support for ActiveRecord 7.0. Thanks to @nickhammond, @ryanwood, @jkowens via \##749 and \##752.
|
|
84
|
+
* Add support for compound foreign keys. Thanks to @Uladzimiro via \##750.
|
|
85
|
+
* Add support for :recursive combined with on_duplicate_key_update: :all. Thanks to @deathwish via \##746.
|
|
86
|
+
|
|
87
|
+
## Changes in 1.2.0
|
|
88
|
+
|
|
89
|
+
### Fixes
|
|
90
|
+
|
|
91
|
+
* Update JDBC MySQL adapter to use mysql2 connection adapter. Thanks to @terencechow via \##744.
|
|
92
|
+
* Fix importing STI models with ActiveRecord 6. Thanks to @clemens1483 via \##743.
|
|
93
|
+
* Use polymorphic_name instead of base_class.name for imports. Thanks to @kmhajjar via \##741.
|
|
94
|
+
* Fix compatibility issue with composite primary keys. Thanks to @dlanileonardo via \##737.
|
|
95
|
+
* Prevent double validation of associations on recursive import.
|
|
96
|
+
|
|
97
|
+
## Changes in 1.1.0
|
|
98
|
+
|
|
99
|
+
### New Features
|
|
100
|
+
|
|
101
|
+
* Add batch progress reporting. Thanks to @gee-forr via \##729.
|
|
102
|
+
|
|
103
|
+
## Changes in 1.0.8
|
|
104
|
+
|
|
105
|
+
### Fixes
|
|
106
|
+
|
|
107
|
+
* Use correct method for clearing query cache. Thanks to @EtienneDepaulis via \##719.
|
|
108
|
+
|
|
109
|
+
## Changes in 1.0.7
|
|
110
|
+
|
|
111
|
+
### New Features
|
|
112
|
+
|
|
113
|
+
* Use @@max_allowed_packet session variable instead of querying SHOW VARIABLES. Thanks to @diclophis via \#706.
|
|
114
|
+
* Add option :track_validation_failures. 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]. Thanks to @rorymckinley via \#684.
|
|
115
|
+
|
|
116
|
+
### Fixes
|
|
117
|
+
|
|
118
|
+
* Prevent mass-assignment errors in Rails strict mode. Thanks to @diclophis via \##709.
|
|
119
|
+
|
|
120
|
+
## Changes in 1.0.6
|
|
121
|
+
|
|
122
|
+
### Fixes
|
|
123
|
+
|
|
124
|
+
* Handle after_initialize callbacks. Thanks to @AhMohsen46 via \#691 and
|
|
125
|
+
\#692.
|
|
126
|
+
* Fix regression introduced in 1.0.4. Explicitly allow adapters to
|
|
127
|
+
support on duplicate key update. Thanks to @dsobiera, @jkowens via \#696.
|
|
128
|
+
|
|
129
|
+
## Changes in 1.0.5
|
|
130
|
+
|
|
131
|
+
### Fixes
|
|
132
|
+
|
|
133
|
+
* Allow serialized attributes to be returned from import. Thanks to @timanovsky, @jkowens via \#660.
|
|
134
|
+
* Return ActiveRecord::Connection from
|
|
135
|
+
ActiveRecord::Base#establish_connection. Thanks to @reverentF via
|
|
136
|
+
\#663.
|
|
137
|
+
* Support PostgreSQL array. Thanks to @ujihisa via \#669.
|
|
138
|
+
* Skip loading association ids when column changed. Thanks to @Aristat
|
|
139
|
+
via \#673.
|
|
140
|
+
|
|
1
141
|
## Changes in 1.0.4
|
|
2
142
|
|
|
3
143
|
### Fixes
|
|
@@ -47,7 +187,7 @@
|
|
|
47
187
|
* Fix import issue for models with Postgresql json/jsonb fields. Thanks
|
|
48
188
|
to @stokarenko via \#594.
|
|
49
189
|
* Fix issue importing models with timestamps that contain timezone
|
|
50
|
-
information.
|
|
190
|
+
information. Thanks to @dekaikiwi, @jkowens via \#598.
|
|
51
191
|
* Ignore :no_returning when using :recursive option. Thanks to @dgollahon, @jkowens
|
|
52
192
|
via \#599.
|
|
53
193
|
|
|
@@ -262,7 +402,7 @@
|
|
|
262
402
|
Thanks to @jkowens via \#301.
|
|
263
403
|
* Allow for custom timestamp columns. Thanks to @mojidabckuu, @jkowens
|
|
264
404
|
via \#401.
|
|
265
|
-
|
|
405
|
+
|
|
266
406
|
### Fixes
|
|
267
407
|
|
|
268
408
|
* Fix ActiveRecord 5 issue coercing boolean values when serializing
|
|
@@ -274,7 +414,7 @@
|
|
|
274
414
|
|
|
275
415
|
* Fix issue where PostgreSQL cannot recognize columns if names
|
|
276
416
|
include mixed case characters. Thanks to @hugobgranja via \#379.
|
|
277
|
-
* Fix an issue for ActiveRecord 5 where serialized fields with
|
|
417
|
+
* Fix an issue for ActiveRecord 5 where serialized fields with
|
|
278
418
|
default values were not being typecast. Thanks to @whistlerbrk,
|
|
279
419
|
@jkowens via \#386.
|
|
280
420
|
* Add option :force_single_insert for MySQL to make sure a single
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Use the official Ruby 3.2 image as a base image
|
|
2
|
+
ARG RUBY_VERSION=3.2
|
|
3
|
+
FROM ruby:${RUBY_VERSION}-bullseye
|
|
4
|
+
|
|
5
|
+
# Set the working directory
|
|
6
|
+
WORKDIR /usr/src/app
|
|
7
|
+
|
|
8
|
+
# Install system packages
|
|
9
|
+
RUN apt-get update -qq && \
|
|
10
|
+
apt-get install -y default-mysql-client postgresql postgresql-contrib vim && \
|
|
11
|
+
apt-get clean
|
|
12
|
+
|
|
13
|
+
# Set environment variables
|
|
14
|
+
ENV AR_VERSION=7.0
|
|
15
|
+
|
|
16
|
+
# Copy all files
|
|
17
|
+
COPY . .
|
|
18
|
+
|
|
19
|
+
# Move sample database.yml and install gems
|
|
20
|
+
RUN mv test/database.yml.sample test/database.yml && \
|
|
21
|
+
bundle install
|
|
22
|
+
|
|
23
|
+
CMD ["irb"]
|
data/Gemfile
CHANGED
|
@@ -1,59 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source 'https://rubygems.org'
|
|
2
4
|
|
|
3
5
|
gemspec
|
|
4
6
|
|
|
5
7
|
version = ENV['AR_VERSION'].to_f
|
|
6
8
|
|
|
7
|
-
mysql2_version = '0.
|
|
8
|
-
mysql2_version = '0.
|
|
9
|
+
mysql2_version = '0.4.0'
|
|
10
|
+
mysql2_version = '0.5.0' if version >= 6.1
|
|
11
|
+
mysql2_version = '0.5.6' if version >= 8.0
|
|
9
12
|
sqlite3_version = '1.3.0'
|
|
10
13
|
sqlite3_version = '1.4.0' if version >= 6.0
|
|
14
|
+
sqlite3_version = '2.2.0' if version >= 8.0
|
|
15
|
+
pg_version = '0.9'
|
|
16
|
+
pg_version = '1.1' if version >= 6.1
|
|
17
|
+
pg_version = '1.5' if version >= 8.0
|
|
11
18
|
|
|
12
19
|
group :development, :test do
|
|
13
|
-
gem 'rubocop'
|
|
20
|
+
gem 'rubocop'
|
|
14
21
|
gem 'rake'
|
|
15
22
|
end
|
|
16
23
|
|
|
17
24
|
# Database Adapters
|
|
18
25
|
platforms :ruby do
|
|
19
26
|
gem "mysql2", "~> #{mysql2_version}"
|
|
20
|
-
gem "pg", "~>
|
|
27
|
+
gem "pg", "~> #{pg_version}"
|
|
21
28
|
gem "sqlite3", "~> #{sqlite3_version}"
|
|
22
|
-
|
|
29
|
+
# seamless_database_pool requires Ruby ~> 2.0
|
|
30
|
+
gem "seamless_database_pool", "~> 1.0.20" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')
|
|
31
|
+
gem "trilogy" if version >= 6.0
|
|
32
|
+
if version >= 6.0 && version <= 7.0
|
|
33
|
+
gem "activerecord-trilogy-adapter"
|
|
34
|
+
end
|
|
23
35
|
end
|
|
24
36
|
|
|
25
37
|
platforms :jruby do
|
|
26
38
|
gem "jdbc-mysql"
|
|
27
39
|
gem "jdbc-postgres"
|
|
28
|
-
gem "activerecord-jdbcsqlite3-adapter"
|
|
29
|
-
gem "activerecord-jdbcmysql-adapter"
|
|
30
|
-
gem "activerecord-jdbcpostgresql-adapter"
|
|
40
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
|
41
|
+
gem "activerecord-jdbcmysql-adapter"
|
|
42
|
+
gem "activerecord-jdbcpostgresql-adapter"
|
|
31
43
|
end
|
|
32
44
|
|
|
33
45
|
# Support libs
|
|
34
|
-
|
|
46
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0")
|
|
47
|
+
gem "factory_bot"
|
|
48
|
+
else
|
|
49
|
+
gem "factory_bot", "~> 5", "< 6.4.5"
|
|
50
|
+
end
|
|
35
51
|
gem "timecop"
|
|
36
52
|
gem "chronic"
|
|
37
|
-
gem "mocha", "~> 1.
|
|
53
|
+
gem "mocha", "~> 2.1.0"
|
|
38
54
|
|
|
39
55
|
# Debugging
|
|
40
|
-
platforms :jruby do
|
|
41
|
-
gem "ruby-debug", "= 0.10.4"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
platforms :mri_19 do
|
|
45
|
-
gem "debugger"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
56
|
platforms :ruby do
|
|
49
57
|
gem "pry-byebug"
|
|
50
|
-
gem "
|
|
58
|
+
gem "pry", "~> 0.14.0"
|
|
51
59
|
end
|
|
52
60
|
|
|
53
|
-
|
|
54
|
-
gem "minitest"
|
|
55
|
-
else
|
|
56
|
-
gem "test-unit"
|
|
57
|
-
end
|
|
61
|
+
gem "minitest"
|
|
58
62
|
|
|
59
63
|
eval_gemfile File.expand_path("../gemfiles/#{version}.gemfile", __FILE__)
|