activerecord-import 1.4.0 → 1.5.1
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 +20 -3
- data/.rubocop.yml +74 -8
- data/.rubocop_todo.yml +6 -16
- data/Brewfile +3 -1
- data/CHANGELOG.md +24 -0
- data/Dockerfile +23 -0
- data/Gemfile +8 -6
- data/README.markdown +21 -6
- data/Rakefile +2 -0
- data/activerecord-import.gemspec +2 -1
- data/benchmarks/benchmark.rb +5 -3
- 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/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 +2 -0
- data/gemfiles/6.1.gemfile +2 -0
- data/gemfiles/7.0.gemfile +3 -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 +2 -0
- 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/adapters/abstract_adapter.rb +8 -5
- 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 +26 -18
- data/lib/activerecord-import/adapters/postgresql_adapter.rb +63 -42
- data/lib/activerecord-import/adapters/sqlite3_adapter.rb +33 -25
- data/lib/activerecord-import/base.rb +3 -1
- data/lib/activerecord-import/import.rb +60 -32
- 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 +2 -0
- data/lib/activerecord-import/value_sets_parser.rb +3 -0
- data/lib/activerecord-import/version.rb +3 -1
- data/lib/activerecord-import.rb +3 -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/database.yml.sample +2 -0
- data/test/import_test.rb +21 -0
- 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 +2 -0
- data/test/models/bike_maker.rb +3 -0
- data/test/models/book.rb +3 -1
- data/test/models/car.rb +2 -0
- data/test/models/card.rb +2 -0
- data/test/models/chapter.rb +2 -0
- data/test/models/customer.rb +8 -4
- data/test/models/deck.rb +2 -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 +8 -4
- data/test/models/playing_card.rb +2 -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 +3 -0
- data/test/models/tag_alias.rb +7 -0
- data/test/models/topic.rb +7 -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 +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 +12 -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 +3 -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 +2 -0
- 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 +2 -1
- data/test/support/postgresql/import_examples.rb +40 -1
- data/test/support/shared_examples/on_duplicate_key_ignore.rb +2 -0
- data/test/support/shared_examples/on_duplicate_key_update.rb +41 -10
- data/test/support/shared_examples/recursive_import.rb +3 -1
- data/test/support/sqlite3/import_examples.rb +2 -1
- data/test/synchronize_test.rb +2 -0
- data/test/test_helper.rb +11 -3
- data/test/value_sets_bytes_parser_test.rb +3 -1
- data/test/value_sets_records_parser_test.rb +3 -1
- metadata +11 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8b122b955b4a926db451a6a3ef72405ade6d69b54876bccb9ea51680486b328
|
4
|
+
data.tar.gz: 3af5c65f25ffb54d338d012aab4f3608513071287c8a759f3ba678850a81f6e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 638f6a8062713b07b1c2ebe866fa647c254d42e594c0fa056b5a710bcd9a2560b2217db73a89f5804c9fc1a71d5de05fc98625771e6225e9e148f58048618079
|
7
|
+
data.tar.gz: 806d66d95034276b0daec9c6c207b8a6187ec0950a44b312267aeef4d491b1c9f5e036641df35950296180f124315fc220e9af5d5b4d4057278176dcf667b1c3
|
data/.github/workflows/test.yaml
CHANGED
@@ -20,19 +20,33 @@ jobs:
|
|
20
20
|
fail-fast: false
|
21
21
|
matrix:
|
22
22
|
ruby:
|
23
|
-
- 3.
|
23
|
+
- 3.2
|
24
24
|
env:
|
25
|
+
- AR_VERSION: '7.1'
|
26
|
+
RUBYOPT: --enable-frozen-string-literal
|
25
27
|
- AR_VERSION: '7.0'
|
26
28
|
RUBYOPT: --enable-frozen-string-literal
|
27
29
|
- AR_VERSION: 6.1
|
28
30
|
RUBYOPT: --enable-frozen-string-literal
|
29
31
|
include:
|
32
|
+
- ruby: 3.1
|
33
|
+
env:
|
34
|
+
AR_VERSION: '7.1'
|
35
|
+
- ruby: 3.1
|
36
|
+
env:
|
37
|
+
AR_VERSION: '7.0'
|
38
|
+
- ruby: 3.1
|
39
|
+
env:
|
40
|
+
AR_VERSION: 6.1
|
30
41
|
- ruby: '3.0'
|
31
42
|
env:
|
32
43
|
AR_VERSION: '7.0'
|
33
44
|
- ruby: '3.0'
|
34
45
|
env:
|
35
46
|
AR_VERSION: 6.1
|
47
|
+
- ruby: jruby
|
48
|
+
env:
|
49
|
+
AR_VERSION: '7.0'
|
36
50
|
- ruby: 2.7
|
37
51
|
env:
|
38
52
|
AR_VERSION: '7.0'
|
@@ -42,6 +56,9 @@ jobs:
|
|
42
56
|
- ruby: 2.7
|
43
57
|
env:
|
44
58
|
AR_VERSION: '6.0'
|
59
|
+
- ruby: jruby-9.3.10.0
|
60
|
+
env:
|
61
|
+
AR_VERSION: '6.1'
|
45
62
|
- ruby: 2.6
|
46
63
|
env:
|
47
64
|
AR_VERSION: 5.2
|
@@ -59,7 +76,7 @@ jobs:
|
|
59
76
|
AR_VERSION: ${{ matrix.env.AR_VERSION }}
|
60
77
|
DB_DATABASE: activerecord_import_test
|
61
78
|
steps:
|
62
|
-
- uses: actions/checkout@
|
79
|
+
- uses: actions/checkout@v4
|
63
80
|
- uses: ruby/setup-ruby@v1
|
64
81
|
with:
|
65
82
|
ruby-version: ${{ matrix.ruby }}
|
@@ -98,7 +115,7 @@ jobs:
|
|
98
115
|
env:
|
99
116
|
AR_VERSION: '7.0'
|
100
117
|
steps:
|
101
|
-
- uses: actions/checkout@
|
118
|
+
- uses: actions/checkout@v4
|
102
119
|
- uses: ruby/setup-ruby@v1
|
103
120
|
with:
|
104
121
|
ruby-version: 2.7
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
|
-
Lint/EndAlignment:
|
4
|
-
AlignWith: variable
|
5
|
-
|
6
3
|
Metrics/AbcSize:
|
7
4
|
Enabled: false
|
8
5
|
|
6
|
+
Metrics/BlockLength:
|
7
|
+
Enabled: false
|
8
|
+
|
9
9
|
Metrics/ClassLength:
|
10
10
|
Enabled: false
|
11
11
|
|
@@ -24,8 +24,8 @@ Metrics/ModuleLength:
|
|
24
24
|
Metrics/PerceivedComplexity:
|
25
25
|
Enabled: false
|
26
26
|
|
27
|
-
Style/
|
28
|
-
|
27
|
+
Style/CommentedKeyword:
|
28
|
+
Enabled: false
|
29
29
|
|
30
30
|
Style/ClassAndModuleChildren:
|
31
31
|
Enabled: false
|
@@ -33,10 +33,25 @@ Style/ClassAndModuleChildren:
|
|
33
33
|
Style/Documentation:
|
34
34
|
Enabled: false
|
35
35
|
|
36
|
-
Style/
|
36
|
+
Style/EvalWithLocation:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Style/ExpandPathArguments:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Style/GuardClause:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Style/IfUnlessModifier:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Style/NumericPredicate:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Style/PercentLiteralDelimiters:
|
37
52
|
Enabled: false
|
38
53
|
|
39
|
-
Style/
|
54
|
+
Style/RedundantBegin:
|
40
55
|
Enabled: false
|
41
56
|
|
42
57
|
Style/SpecialGlobalVars:
|
@@ -45,5 +60,56 @@ Style/SpecialGlobalVars:
|
|
45
60
|
Style/StringLiterals:
|
46
61
|
Enabled: false
|
47
62
|
|
48
|
-
Style/
|
63
|
+
Style/SymbolArray:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
Style/TrailingCommaInArrayLiteral:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
Layout/ArgumentAlignment:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
Layout/ParameterAlignment:
|
73
|
+
EnforcedStyle: with_fixed_indentation
|
74
|
+
|
75
|
+
Layout/EndAlignment:
|
76
|
+
EnforcedStyleAlignWith: variable
|
77
|
+
|
78
|
+
Layout/ElseAlignment:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Layout/EmptyLineAfterGuardClause:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
Layout/HeredocIndentation:
|
85
|
+
Enabled: false
|
86
|
+
|
87
|
+
Layout/SpaceInsideParens:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
Layout/SpaceInsidePercentLiteralDelimiters:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
Lint/ErbNewArguments:
|
94
|
+
Enabled: false
|
95
|
+
|
96
|
+
Lint/MissingCopEnableDirective:
|
97
|
+
Enabled: false
|
98
|
+
|
99
|
+
Lint/PercentStringArray:
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
Naming/HeredocDelimiterNaming:
|
103
|
+
Enabled: false
|
104
|
+
|
105
|
+
Naming/MethodParameterName:
|
106
|
+
Enabled: false
|
107
|
+
|
108
|
+
Security/YAMLLoad:
|
109
|
+
Enabled: false
|
110
|
+
|
111
|
+
Gemspec/RequiredRubyVersion:
|
112
|
+
Enabled: false
|
113
|
+
|
114
|
+
Bundler/OrderedGems:
|
49
115
|
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -1,36 +1,26 @@
|
|
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
|
-
- 'lib/activerecord-import/import.rb'
|
26
|
+
- 'test/support/shared_examples/recursive_import.rb'
|
data/Brewfile
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
## Changes in 1.5.1
|
2
|
+
|
3
|
+
### Fixes
|
4
|
+
|
5
|
+
* Stop memoizing schema_columns_hash so dynamic schema changes are picked up. Thanks to @koshigoe via \##812.
|
6
|
+
|
7
|
+
## Changes in 1.5.0
|
8
|
+
|
9
|
+
### New Features
|
10
|
+
|
11
|
+
* Add Rails 7.1 support. Thanks to @gucki via \##807.
|
12
|
+
* Add support for alias attributes. Thanks to @leonidkroka via \##799.
|
13
|
+
|
14
|
+
### Fixes
|
15
|
+
|
16
|
+
* Support for multi-byte column names when splitting queries. Thanks to @TakuyaKurimoto via \##801.
|
17
|
+
* Fix issue with track_validation_failures when import models. Thanks to @OtaYohihiro via \##798.
|
18
|
+
|
19
|
+
## Changes in 1.4.1
|
20
|
+
|
21
|
+
### Fixes
|
22
|
+
|
23
|
+
* Fix importing models that have required belongs_to associations and use composite primary keys. Thanks to @thoughtbot-summer via \##783.
|
24
|
+
|
1
25
|
## Changes in 1.4.0
|
2
26
|
|
3
27
|
### New Features
|
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,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
@@ -13,7 +15,7 @@ pg_version = '0.9'
|
|
13
15
|
pg_version = '1.1' if version >= 6.1
|
14
16
|
|
15
17
|
group :development, :test do
|
16
|
-
gem 'rubocop'
|
18
|
+
gem 'rubocop'
|
17
19
|
gem 'rake'
|
18
20
|
end
|
19
21
|
|
@@ -29,16 +31,16 @@ end
|
|
29
31
|
platforms :jruby do
|
30
32
|
gem "jdbc-mysql"
|
31
33
|
gem "jdbc-postgres"
|
32
|
-
gem "activerecord-jdbcsqlite3-adapter"
|
33
|
-
gem "activerecord-jdbcmysql-adapter"
|
34
|
-
gem "activerecord-jdbcpostgresql-adapter"
|
34
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
35
|
+
gem "activerecord-jdbcmysql-adapter"
|
36
|
+
gem "activerecord-jdbcpostgresql-adapter"
|
35
37
|
end
|
36
38
|
|
37
39
|
# Support libs
|
38
40
|
gem "factory_bot"
|
39
41
|
gem "timecop"
|
40
42
|
gem "chronic"
|
41
|
-
gem "mocha", "~> 1.
|
43
|
+
gem "mocha", "~> 2.1.0"
|
42
44
|
|
43
45
|
# Debugging
|
44
46
|
platforms :jruby do
|
@@ -47,7 +49,7 @@ end
|
|
47
49
|
|
48
50
|
platforms :ruby do
|
49
51
|
gem "pry-byebug"
|
50
|
-
gem "pry", "~> 0.
|
52
|
+
gem "pry", "~> 0.14.0"
|
51
53
|
end
|
52
54
|
|
53
55
|
if version >= 4.0
|
data/README.markdown
CHANGED
@@ -245,8 +245,8 @@ Book.import columns, books, batch_size: 2, batch_progress: my_proc
|
|
245
245
|
|
246
246
|
#### Recursive
|
247
247
|
|
248
|
-
|
249
|
-
hashes or arrays as recursive inputs.
|
248
|
+
> **Note**
|
249
|
+
> This only works with PostgreSQL and ActiveRecord objects. This won't work with hashes or arrays as recursive inputs.
|
250
250
|
|
251
251
|
Assume that Books <code>has_many</code> Reviews.
|
252
252
|
|
@@ -268,9 +268,9 @@ Key | Options | Default | Descrip
|
|
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
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
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
|
-
:on_duplicate_key_ignore | `true`/`false` | `false` | Allows skipping records with duplicate keys. See [here](
|
271
|
+
:on_duplicate_key_ignore | `true`/`false` | `false` | Allows skipping records with duplicate keys. See [here](#duplicate-key-ignore) for more details.
|
272
272
|
:ignore | `true`/`false` | `false` | Alias for :on_duplicate_key_ignore.
|
273
|
-
:on_duplicate_key_update | :all, `Array`, `Hash` | N/A | Allows upsert logic to be used. See [here](
|
273
|
+
:on_duplicate_key_update | :all, `Array`, `Hash` | N/A | Allows upsert logic to be used. See [here](#duplicate-key-update) for more details.
|
274
274
|
:synchronize | `Array` | N/A | An array of ActiveRecord instances. This synchronizes existing instances in memory with updates from the import.
|
275
275
|
:timestamps | `true`/`false` | `true` | Enables/disables timestamps on imported records.
|
276
276
|
:recursive | `true`/`false` | `false` | Imports has_many/has_one associations (PostgreSQL only).
|
@@ -434,7 +434,8 @@ Should you wish to specify those columns, you may use the option `timestamps: fa
|
|
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
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
|
-
|
437
|
+
> **Note**
|
438
|
+
> If you are using ActiveRecord 7.0 or later, please use `ActiveRecord.default_timezone` instead.
|
438
439
|
|
439
440
|
### Callbacks
|
440
441
|
|
@@ -506,7 +507,8 @@ This allows an external gem to dynamically add an adapter without the need to ad
|
|
506
507
|
|
507
508
|
### Requiring
|
508
509
|
|
509
|
-
Note
|
510
|
+
> **Note**
|
511
|
+
> These instructions will only work if you are using version 0.2.0 or higher.
|
510
512
|
|
511
513
|
#### Autoloading via Bundler
|
512
514
|
|
@@ -624,6 +626,19 @@ AR_VERSION=7.0 bundle exec rake test:postgresql test:sqlite3 test:mysql2
|
|
624
626
|
|
625
627
|
Once you have pushed up your changes, you can find your CI results [here](https://github.com/zdennis/activerecord-import/actions).
|
626
628
|
|
629
|
+
#### Docker Setup
|
630
|
+
|
631
|
+
Before you begin, make sure you have [Docker](https://www.docker.com/products/docker-desktop/) and [Docker Compose](https://docs.docker.com/compose/) installed on your machine. If you don't, you can install both via Homebrew using the following command:
|
632
|
+
|
633
|
+
```bash
|
634
|
+
brew install docker && brew install docker-compose
|
635
|
+
```
|
636
|
+
##### Steps
|
637
|
+
|
638
|
+
1. In your terminal run `docker-compose up --build`
|
639
|
+
1. In another tab/window run `docker-compose exec app bash`
|
640
|
+
1. In that same terminal run the mysql2 test by running `bundle exec rake test:mysql2`
|
641
|
+
|
627
642
|
## Issue Triage [![Open Source Helpers](https://www.codetriage.com/zdennis/activerecord-import/badges/users.svg)](https://www.codetriage.com/zdennis/activerecord-import)
|
628
643
|
|
629
644
|
You can triage issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to activerecord-import on CodeTriage](https://www.codetriage.com/zdennis/activerecord-import).
|
data/Rakefile
CHANGED
data/activerecord-import.gemspec
CHANGED
data/benchmarks/benchmark.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
require "fileutils"
|
3
5
|
require "active_record"
|
@@ -39,7 +41,7 @@ require File.join(benchmark_dir, "../test/schema/generic_schema")
|
|
39
41
|
adapter_schema = File.join(benchmark_dir, "schema/#{options.adapter}_schema.rb")
|
40
42
|
require adapter_schema if File.exist?(adapter_schema)
|
41
43
|
|
42
|
-
Dir[File.dirname(__FILE__)
|
44
|
+
Dir["#{File.dirname(__FILE__)}/models/*.rb"].sort.each { |file| require file }
|
43
45
|
|
44
46
|
require File.join( benchmark_dir, 'lib', "#{options.adapter}_benchmark" )
|
45
47
|
|
@@ -51,8 +53,8 @@ else
|
|
51
53
|
end
|
52
54
|
|
53
55
|
letter = options.adapter[0].chr
|
54
|
-
clazz_str = letter.upcase + options.adapter[1
|
55
|
-
clazz = Object.const_get( clazz_str
|
56
|
+
clazz_str = letter.upcase + options.adapter[1..].downcase
|
57
|
+
clazz = Object.const_get( "#{clazz_str}Benchmark" )
|
56
58
|
|
57
59
|
benchmarks = []
|
58
60
|
options.number_of_objects.each do |num|
|
data/benchmarks/lib/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class BenchmarkBase
|
2
4
|
attr_reader :results
|
3
5
|
|
@@ -25,11 +27,11 @@ class BenchmarkBase
|
|
25
27
|
# An OpenStruct object with the following attributes:
|
26
28
|
# * description - the description of the benchmark ran
|
27
29
|
# * tms - a Benchmark::Tms containing the results of the benchmark
|
28
|
-
def bm( description )
|
30
|
+
def bm( description, &block )
|
29
31
|
tms = nil
|
30
32
|
puts "Benchmarking #{description}"
|
31
33
|
|
32
|
-
Benchmark.bm { |x| tms = x.report
|
34
|
+
Benchmark.bm { |x| tms = x.report(&block) }
|
33
35
|
delete_all
|
34
36
|
failed = false
|
35
37
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'optparse'
|
2
4
|
require 'ostruct'
|
3
5
|
|
@@ -8,7 +10,7 @@ require 'ostruct'
|
|
8
10
|
# * t - the table types to test. ie: myisam, innodb, memory, temporary, etc.
|
9
11
|
#
|
10
12
|
module BenchmarkOptionParser
|
11
|
-
BANNER = "Usage: ruby #{$0} [options]\nSee ruby #{$0} -h for more options."
|
13
|
+
BANNER = "Usage: ruby #{$0} [options]\nSee ruby #{$0} -h for more options."
|
12
14
|
|
13
15
|
def self.print_banner
|
14
16
|
puts BANNER
|
@@ -27,7 +29,7 @@ module BenchmarkOptionParser
|
|
27
29
|
print_valid_table_types( options, prefix: " " )
|
28
30
|
end
|
29
31
|
|
30
|
-
# TODO IMPLEMENT THIS
|
32
|
+
# TODO: IMPLEMENT THIS
|
31
33
|
def self.print_valid_table_types( options, hsh = { prefix: '' } )
|
32
34
|
if !options.table_types.keys.empty?
|
33
35
|
options.table_types.keys.sort.each { |type| puts hsh[:prefix].to_s + type.to_s }
|
data/benchmarks/lib/float.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'erb'
|
2
4
|
|
3
5
|
module OutputToHTML
|
4
|
-
TEMPLATE_HEADER = <<"EOT"
|
6
|
+
TEMPLATE_HEADER = <<"EOT"
|
5
7
|
<div>
|
6
8
|
All times are rounded to the nearest thousandth for display purposes. Speedups next to each time are computed
|
7
9
|
before any rounding occurs. Also, all speedup calculations are computed by comparing a given time against
|
@@ -9,7 +11,7 @@ module OutputToHTML
|
|
9
11
|
</div>
|
10
12
|
EOT
|
11
13
|
|
12
|
-
TEMPLATE = <<"EOT"
|
14
|
+
TEMPLATE = <<"EOT"
|
13
15
|
<style>
|
14
16
|
td#benchmarkTitle {
|
15
17
|
border: 1px solid black;
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
version: "3.5"
|
2
|
+
|
3
|
+
services:
|
4
|
+
mysql:
|
5
|
+
platform: linux/x86_64
|
6
|
+
image: mysql:5.7
|
7
|
+
volumes:
|
8
|
+
- mysql-data:/var/lib/mysql
|
9
|
+
ports:
|
10
|
+
- "3306:3306"
|
11
|
+
|
12
|
+
postgresql:
|
13
|
+
image: postgres:latest
|
14
|
+
volumes:
|
15
|
+
- postgresql-data:/var/lib/postgresql/data
|
16
|
+
ports:
|
17
|
+
- "5432:5432"
|
18
|
+
|
19
|
+
app:
|
20
|
+
build:
|
21
|
+
context: .
|
22
|
+
environment:
|
23
|
+
DB_HOST: mysql
|
24
|
+
AR_VERSION: 7.0
|
25
|
+
volumes:
|
26
|
+
- .:/usr/src/app
|
27
|
+
depends_on:
|
28
|
+
- mysql
|
29
|
+
- postgresql
|
30
|
+
command: tail -f /dev/null
|
31
|
+
|
32
|
+
volumes:
|
33
|
+
mysql-data:
|
34
|
+
postgresql-data:
|
data/gemfiles/4.2.gemfile
CHANGED
data/gemfiles/5.0.gemfile
CHANGED
data/gemfiles/5.1.gemfile
CHANGED
data/gemfiles/5.2.gemfile
CHANGED
data/gemfiles/6.0.gemfile
CHANGED
data/gemfiles/6.1.gemfile
CHANGED
data/gemfiles/7.0.gemfile
CHANGED