activerecord-import 1.0.2 → 1.7.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.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yaml +151 -0
  3. data/.gitignore +5 -0
  4. data/.rubocop.yml +74 -8
  5. data/.rubocop_todo.yml +10 -16
  6. data/Brewfile +3 -1
  7. data/CHANGELOG.md +138 -3
  8. data/Dockerfile +23 -0
  9. data/Gemfile +24 -14
  10. data/LICENSE +21 -56
  11. data/README.markdown +108 -60
  12. data/Rakefile +3 -0
  13. data/activerecord-import.gemspec +6 -5
  14. data/benchmarks/benchmark.rb +10 -4
  15. data/benchmarks/lib/base.rb +4 -2
  16. data/benchmarks/lib/cli_parser.rb +4 -2
  17. data/benchmarks/lib/float.rb +2 -0
  18. data/benchmarks/lib/mysql2_benchmark.rb +2 -0
  19. data/benchmarks/lib/output_to_csv.rb +2 -0
  20. data/benchmarks/lib/output_to_html.rb +4 -2
  21. data/benchmarks/models/test_innodb.rb +2 -0
  22. data/benchmarks/models/test_memory.rb +2 -0
  23. data/benchmarks/models/test_myisam.rb +2 -0
  24. data/benchmarks/schema/{mysql_schema.rb → mysql2_schema.rb} +2 -0
  25. data/docker-compose.yml +34 -0
  26. data/gemfiles/4.2.gemfile +2 -0
  27. data/gemfiles/5.0.gemfile +2 -0
  28. data/gemfiles/5.1.gemfile +2 -0
  29. data/gemfiles/5.2.gemfile +2 -0
  30. data/gemfiles/6.0.gemfile +4 -1
  31. data/gemfiles/6.1.gemfile +4 -1
  32. data/gemfiles/7.0.gemfile +4 -0
  33. data/gemfiles/7.1.gemfile +3 -0
  34. data/lib/activerecord-import/active_record/adapters/abstract_adapter.rb +2 -0
  35. data/lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb +6 -4
  36. data/lib/activerecord-import/active_record/adapters/jdbcpostgresql_adapter.rb +2 -0
  37. data/lib/activerecord-import/active_record/adapters/jdbcsqlite3_adapter.rb +2 -0
  38. data/lib/activerecord-import/active_record/adapters/mysql2_adapter.rb +2 -0
  39. data/lib/activerecord-import/active_record/adapters/postgresql_adapter.rb +2 -0
  40. data/lib/activerecord-import/active_record/adapters/seamless_database_pool_adapter.rb +2 -0
  41. data/lib/activerecord-import/active_record/adapters/sqlite3_adapter.rb +2 -0
  42. data/lib/activerecord-import/active_record/adapters/trilogy_adapter.rb +8 -0
  43. data/lib/activerecord-import/adapters/abstract_adapter.rb +14 -5
  44. data/lib/activerecord-import/adapters/em_mysql2_adapter.rb +2 -0
  45. data/lib/activerecord-import/adapters/mysql2_adapter.rb +2 -0
  46. data/lib/activerecord-import/adapters/mysql_adapter.rb +33 -25
  47. data/lib/activerecord-import/adapters/postgresql_adapter.rb +69 -56
  48. data/lib/activerecord-import/adapters/sqlite3_adapter.rb +39 -39
  49. data/lib/activerecord-import/adapters/trilogy_adapter.rb +7 -0
  50. data/lib/activerecord-import/base.rb +10 -2
  51. data/lib/activerecord-import/import.rb +162 -65
  52. data/lib/activerecord-import/mysql2.rb +2 -0
  53. data/lib/activerecord-import/postgresql.rb +2 -0
  54. data/lib/activerecord-import/sqlite3.rb +2 -0
  55. data/lib/activerecord-import/synchronize.rb +3 -1
  56. data/lib/activerecord-import/value_sets_parser.rb +5 -0
  57. data/lib/activerecord-import/version.rb +3 -1
  58. data/lib/activerecord-import.rb +2 -1
  59. data/test/adapters/jdbcmysql.rb +2 -0
  60. data/test/adapters/jdbcpostgresql.rb +2 -0
  61. data/test/adapters/jdbcsqlite3.rb +2 -0
  62. data/test/adapters/makara_postgis.rb +2 -0
  63. data/test/adapters/mysql2.rb +2 -0
  64. data/test/adapters/mysql2_makara.rb +2 -0
  65. data/test/adapters/mysql2spatial.rb +2 -0
  66. data/test/adapters/postgis.rb +2 -0
  67. data/test/adapters/postgresql.rb +2 -0
  68. data/test/adapters/postgresql_makara.rb +2 -0
  69. data/test/adapters/seamless_database_pool.rb +2 -0
  70. data/test/adapters/spatialite.rb +2 -0
  71. data/test/adapters/sqlite3.rb +2 -0
  72. data/test/adapters/trilogy.rb +9 -0
  73. data/test/database.yml.sample +7 -0
  74. data/test/{travis → github}/database.yml +7 -1
  75. data/test/import_test.rb +93 -2
  76. data/test/jdbcmysql/import_test.rb +5 -3
  77. data/test/jdbcpostgresql/import_test.rb +4 -2
  78. data/test/jdbcsqlite3/import_test.rb +4 -2
  79. data/test/makara_postgis/import_test.rb +4 -2
  80. data/test/models/account.rb +2 -0
  81. data/test/models/alarm.rb +2 -0
  82. data/test/models/animal.rb +8 -0
  83. data/test/models/author.rb +7 -0
  84. data/test/models/bike_maker.rb +3 -0
  85. data/test/models/book.rb +7 -2
  86. data/test/models/car.rb +2 -0
  87. data/test/models/card.rb +5 -0
  88. data/test/models/chapter.rb +2 -0
  89. data/test/models/composite_book.rb +19 -0
  90. data/test/models/composite_chapter.rb +9 -0
  91. data/test/models/customer.rb +18 -0
  92. data/test/models/deck.rb +8 -0
  93. data/test/models/dictionary.rb +2 -0
  94. data/test/models/discount.rb +2 -0
  95. data/test/models/end_note.rb +2 -0
  96. data/test/models/group.rb +2 -0
  97. data/test/models/order.rb +17 -0
  98. data/test/models/playing_card.rb +4 -0
  99. data/test/models/promotion.rb +2 -0
  100. data/test/models/question.rb +2 -0
  101. data/test/models/rule.rb +2 -0
  102. data/test/models/tag.rb +9 -1
  103. data/test/models/tag_alias.rb +11 -0
  104. data/test/models/topic.rb +7 -0
  105. data/test/models/user.rb +2 -0
  106. data/test/models/user_token.rb +2 -0
  107. data/test/models/vendor.rb +2 -0
  108. data/test/models/widget.rb +2 -0
  109. data/test/mysql2/import_test.rb +5 -3
  110. data/test/mysql2_makara/import_test.rb +5 -3
  111. data/test/mysqlspatial2/import_test.rb +5 -3
  112. data/test/postgis/import_test.rb +4 -2
  113. data/test/postgresql/import_test.rb +4 -2
  114. data/test/schema/generic_schema.rb +37 -1
  115. data/test/schema/jdbcpostgresql_schema.rb +3 -1
  116. data/test/schema/mysql2_schema.rb +2 -0
  117. data/test/schema/postgis_schema.rb +3 -1
  118. data/test/schema/postgresql_schema.rb +47 -0
  119. data/test/schema/sqlite3_schema.rb +2 -0
  120. data/test/schema/version.rb +2 -0
  121. data/test/sqlite3/import_test.rb +4 -2
  122. data/test/support/active_support/test_case_extensions.rb +2 -0
  123. data/test/support/assertions.rb +2 -0
  124. data/test/support/factories.rb +2 -0
  125. data/test/support/generate.rb +4 -2
  126. data/test/support/mysql/import_examples.rb +2 -1
  127. data/test/support/postgresql/import_examples.rb +108 -2
  128. data/test/support/shared_examples/on_duplicate_key_ignore.rb +2 -0
  129. data/test/support/shared_examples/on_duplicate_key_update.rb +78 -9
  130. data/test/support/shared_examples/recursive_import.rb +98 -1
  131. data/test/support/sqlite3/import_examples.rb +2 -1
  132. data/test/synchronize_test.rb +2 -0
  133. data/test/test_helper.rb +33 -6
  134. data/test/trilogy/import_test.rb +7 -0
  135. data/test/value_sets_bytes_parser_test.rb +3 -1
  136. data/test/value_sets_records_parser_test.rb +3 -1
  137. metadata +42 -16
  138. data/.travis.yml +0 -70
  139. data/gemfiles/3.2.gemfile +0 -2
  140. data/gemfiles/4.0.gemfile +0 -2
  141. data/gemfiles/4.1.gemfile +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5448c6493533f39965a0b3cd0f00e3d2811e7f8feaa2f806e20b47d8db504c27
4
- data.tar.gz: fde9e0e991022d01d339da3da9b89d0523771533fc684d3d955af91b718bede2
3
+ metadata.gz: 5aeed63fcbc9ad647ab901931265d2765baf5d0e5a1e9d2cf2c68af32dd5e1be
4
+ data.tar.gz: 47480cc7244aada4bc69ba28043e8ab85ae1cece4420db4453400425a5773126
5
5
  SHA512:
6
- metadata.gz: 1048e6bb250eb8cedb71d37dad9e13245799638e948f83016e3301ea933418327fe294438ab862d0cf1c521da51fabd8ac648f16798d1f44a62cb4784176a60a
7
- data.tar.gz: e764901dc217df8fb650a788064fcd274d7141e0a3e201ecc9011aa0ce5ce89ff7bb06d899543e084543bf52e54d8feb81c6a17d464e3a81b7df5ee187c2614d
6
+ metadata.gz: 5f6b5749dd6ce81784f7016c6227a6d0f5047c59a45beb13616853a89599ac507241012a92c3e4f9996c7a465d4d926e0e8d1183af1854f7a0c8a05e2e59219f
7
+ data.tar.gz: 72b00e7a5c61af3923b618ebe0d96f945a7af145f38ec5312962220b925e1dfc918da6028bb48d8ff7842c32584b34b06cec8fd8288dbb83212ca035f7a16c08
@@ -0,0 +1,151 @@
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_ROOT_PASSWORD: root
25
+ MYSQL_USER: github
26
+ MYSQL_PASSWORD: github
27
+ MYSQL_DATABASE: activerecord_import_test
28
+ options: >-
29
+ --health-cmd "mysqladmin ping -h localhost"
30
+ --health-interval 10s
31
+ --health-timeout 5s
32
+ --health-retries 5
33
+ strategy:
34
+ fail-fast: false
35
+ matrix:
36
+ ruby:
37
+ - 3.3
38
+ env:
39
+ - AR_VERSION: '7.1'
40
+ RUBYOPT: --enable-frozen-string-literal
41
+ - AR_VERSION: '7.0'
42
+ RUBYOPT: --enable-frozen-string-literal
43
+ - AR_VERSION: 6.1
44
+ RUBYOPT: --enable-frozen-string-literal
45
+ include:
46
+ - ruby: 3.2
47
+ env:
48
+ AR_VERSION: '7.1'
49
+ - ruby: 3.2
50
+ env:
51
+ AR_VERSION: '7.0'
52
+ - ruby: 3.2
53
+ env:
54
+ AR_VERSION: 6.1
55
+ - ruby: 3.1
56
+ env:
57
+ AR_VERSION: '7.1'
58
+ - ruby: 3.1
59
+ env:
60
+ AR_VERSION: '7.0'
61
+ - ruby: 3.1
62
+ env:
63
+ AR_VERSION: 6.1
64
+ - ruby: '3.0'
65
+ env:
66
+ AR_VERSION: '7.0'
67
+ - ruby: '3.0'
68
+ env:
69
+ AR_VERSION: 6.1
70
+ - ruby: jruby-9.4.5.0
71
+ env:
72
+ AR_VERSION: '7.0'
73
+ - ruby: 2.7
74
+ env:
75
+ AR_VERSION: '7.0'
76
+ - ruby: 2.7
77
+ env:
78
+ AR_VERSION: 6.1
79
+ - ruby: 2.7
80
+ env:
81
+ AR_VERSION: '6.0'
82
+ - ruby: jruby-9.3.10.0
83
+ env:
84
+ AR_VERSION: '6.1'
85
+ - ruby: 2.6
86
+ env:
87
+ AR_VERSION: 5.2
88
+ - ruby: 2.6
89
+ env:
90
+ AR_VERSION: 5.1
91
+ - ruby: 2.4
92
+ env:
93
+ AR_VERSION: '5.0'
94
+ - ruby: 2.4
95
+ env:
96
+ AR_VERSION: 4.2
97
+ runs-on: ubuntu-latest
98
+ env:
99
+ AR_VERSION: ${{ matrix.env.AR_VERSION }}
100
+ DB_DATABASE: activerecord_import_test
101
+ steps:
102
+ - uses: actions/checkout@v4
103
+ - uses: ruby/setup-ruby@v1
104
+ with:
105
+ ruby-version: ${{ matrix.ruby }}
106
+ bundler-cache: true
107
+ rubygems: latest
108
+ - name: Set up databases
109
+ run: |
110
+ sudo /etc/init.d/mysql start
111
+ mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }} CHARACTER SET utf8 COLLATE utf8_general_ci;' -u root -proot
112
+ psql -h localhost -U postgres -c 'create database ${{ env.DB_DATABASE }};'
113
+ psql -h localhost -U postgres -d ${{ env.DB_DATABASE }} -c 'create extension if not exists hstore;'
114
+ psql -h localhost -U postgres -c 'create extension if not exists postgis;'
115
+ psql -h localhost -U postgres -c 'create extension if not exists "uuid-ossp";'
116
+ cp test/github/database.yml test/database.yml
117
+ env:
118
+ PGPASSWORD: postgres
119
+ - name: Run tests with mysql2
120
+ run: |
121
+ bundle exec rake test:mysql2
122
+ bundle exec rake test:mysql2_makara
123
+ bundle exec rake test:mysql2spatial
124
+ - name: Run tests with postgresql
125
+ run: |
126
+ bundle exec rake test:postgis
127
+ bundle exec rake test:postgresql
128
+ bundle exec rake test:postgresql_makara
129
+ - name: Run tests with seamless_database_pool
130
+ run: |
131
+ bundle exec rake test:seamless_database_pool
132
+ if: ${{ matrix.ruby < '3.0' }}
133
+ - name: Run tests with sqlite
134
+ run: |
135
+ bundle exec rake test:spatialite
136
+ bundle exec rake test:sqlite3
137
+ - name: Run trilogy tests
138
+ if: ${{ matrix.env.AR_VERSION >= '7.0' && !startsWith(matrix.ruby, 'jruby') }}
139
+ run: bundle exec rake test:trilogy
140
+ lint:
141
+ runs-on: ubuntu-latest
142
+ env:
143
+ AR_VERSION: '7.0'
144
+ steps:
145
+ - uses: actions/checkout@v4
146
+ - uses: ruby/setup-ruby@v1
147
+ with:
148
+ ruby-version: 2.7
149
+ bundler-cache: true
150
+ - name: Run Rubocop
151
+ 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,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/AlignParameters:
28
- EnforcedStyle: with_fixed_indentation
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/ElseAlignment:
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/SpaceInsideParens:
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/TrailingCommaInLiteral:
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,30 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-03-17 18:14:55 -0700 using RuboCop version 0.38.0.
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: 4
22
- # Cop supports --auto-correct.
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
- # Cop supports --auto-correct.
31
- # Configuration parameters: Keywords.
32
- # Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
33
- Style/CommentAnnotation:
24
+ Style/CombinableLoops:
34
25
  Exclude:
35
- - 'benchmarks/lib/cli_parser.rb'
36
- - 'lib/activerecord-import/import.rb'
26
+ - 'test/support/shared_examples/recursive_import.rb'
27
+
28
+ Naming/FileName:
29
+ Exclude:
30
+ - 'lib/activerecord-import.rb'
data/Brewfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  brew "mysql"
2
4
  brew "postgresql"
3
- brew "sqlite"
5
+ brew "sqlite"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,138 @@
1
+ ## Changes in 1.7.0
2
+
3
+ ### New Features
4
+
5
+ * Add support for ActiveRecord 7.1 composite primary keys. Thanks to @fragkakis via \##837.
6
+ * Add support for upserting associations when doing recursive imports. Thanks to @ramblex via \##778.
7
+
8
+ ## Changes in 1.6.0
9
+
10
+ ### New Features
11
+
12
+ * Add trilogy adapter support. Thanks to @zmariscal via \##825.
13
+
14
+ ### Fixes
15
+
16
+ * Use the locking_enabled? method provided by activerecord to decide whether the lock field should be updated. Thanks to @dombesz via \##822.
17
+
18
+ ## Changes in 1.5.1
19
+
20
+ ### Fixes
21
+
22
+ * Stop memoizing schema_columns_hash so dynamic schema changes are picked up. Thanks to @koshigoe via \##812.
23
+
24
+ ## Changes in 1.5.0
25
+
26
+ ### New Features
27
+
28
+ * Add Rails 7.1 support. Thanks to @gucki via \##807.
29
+ * Add support for alias attributes. Thanks to @leonidkroka via \##799.
30
+
31
+ ### Fixes
32
+
33
+ * Support for multi-byte column names when splitting queries. Thanks to @TakuyaKurimoto via \##801.
34
+ * Fix issue with track_validation_failures when import models. Thanks to @OtaYohihiro via \##798.
35
+
36
+ ## Changes in 1.4.1
37
+
38
+ ### Fixes
39
+
40
+ * Fix importing models that have required belongs_to associations and use composite primary keys. Thanks to @thoughtbot-summer via \##783.
41
+
42
+ ## Changes in 1.4.0
43
+
44
+ ### New Features
45
+
46
+ * Enable compatibility with frozen string literals. Thanks to @desheikh via \##760.
47
+
48
+ ## Changes in 1.3.0
49
+
50
+ ### Fixes
51
+
52
+ * Ensure correct timestamp values are returned for models after insert. Thanks to @kos1kov via \##756.
53
+ * Restore database_version method to public scope. Thanks to @beauraF via \##753.
54
+
55
+ ### New Features
56
+
57
+ * Add support for ActiveRecord 7.0. Thanks to @nickhammond, @ryanwood, @jkowens via \##749 and \##752.
58
+ * Add support for compound foreign keys. Thanks to @Uladzimiro via \##750.
59
+ * Add support for :recursive combined with on_duplicate_key_update: :all. Thanks to @deathwish via \##746.
60
+
61
+ ## Changes in 1.2.0
62
+
63
+ ### Fixes
64
+
65
+ * Update JDBC MySQL adapter to use mysql2 connection adapter. Thanks to @terencechow via \##744.
66
+ * Fix importing STI models with ActiveRecord 6. Thanks to @clemens1483 via \##743.
67
+ * Use polymorphic_name instead of base_class.name for imports. Thanks to @kmhajjar via \##741.
68
+ * Fix compatibility issue with composite primary keys. Thanks to @dlanileonardo via \##737.
69
+ * Prevent double validation of associations on recursive import.
70
+
71
+ ## Changes in 1.1.0
72
+
73
+ ### New Features
74
+
75
+ * Add batch progress reporting. Thanks to @gee-forr via \##729.
76
+
77
+ ## Changes in 1.0.8
78
+
79
+ ### Fixes
80
+
81
+ * Use correct method for clearing query cache. Thanks to @EtienneDepaulis via \##719.
82
+
83
+ ## Changes in 1.0.7
84
+
85
+ ### New Features
86
+
87
+ * Use @@max_allowed_packet session variable instead of querying SHOW VARIABLES. Thanks to @diclophis via \#706.
88
+ * 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.
89
+
90
+ ### Fixes
91
+
92
+ * Prevent mass-assignment errors in Rails strict mode. Thanks to @diclophis via \##709.
93
+
94
+ ## Changes in 1.0.6
95
+
96
+ ### Fixes
97
+
98
+ * Handle after_initialize callbacks. Thanks to @AhMohsen46 via \#691 and
99
+ \#692.
100
+ * Fix regression introduced in 1.0.4. Explicitly allow adapters to
101
+ support on duplicate key update. Thanks to @dsobiera, @jkowens via \#696.
102
+
103
+ ## Changes in 1.0.5
104
+
105
+ ### Fixes
106
+
107
+ * Allow serialized attributes to be returned from import. Thanks to @timanovsky, @jkowens via \#660.
108
+ * Return ActiveRecord::Connection from
109
+ ActiveRecord::Base#establish_connection. Thanks to @reverentF via
110
+ \#663.
111
+ * Support PostgreSQL array. Thanks to @ujihisa via \#669.
112
+ * Skip loading association ids when column changed. Thanks to @Aristat
113
+ via \#673.
114
+
115
+ ## Changes in 1.0.4
116
+
117
+ ### Fixes
118
+
119
+ * Use prepend pattern for ActiveRecord::Base#establish_connection patching. Thanks to @dombesz via \#648.
120
+ * Fix NoMethodError when using PostgreSQL ENUM types. Thanks to @sebcoetzee via \#651.
121
+ * Fix issue updating optimistic lock in Postgres. Thanks to @timanovsky
122
+ via \#656.
123
+
124
+ ## Changes in 1.0.3
125
+
126
+ ### New Features
127
+
128
+ * Add support for ActiveRecord 6.1.0.alpha. Thanks to @imtayadeway via
129
+ \#642.
130
+
131
+ ### Fixes
132
+
133
+ * Return an empty array for results instead of nil when importing empty
134
+ array. Thanks to @gyfis via \#636.
135
+
1
136
  ## Changes in 1.0.2
2
137
 
3
138
  ### New Features
@@ -26,7 +161,7 @@
26
161
  * Fix import issue for models with Postgresql json/jsonb fields. Thanks
27
162
  to @stokarenko via \#594.
28
163
  * Fix issue importing models with timestamps that contain timezone
29
- information. Thaks to @dekaikiwi, @jkowens via \#598.
164
+ information. Thanks to @dekaikiwi, @jkowens via \#598.
30
165
  * Ignore :no_returning when using :recursive option. Thanks to @dgollahon, @jkowens
31
166
  via \#599.
32
167
 
@@ -241,7 +376,7 @@
241
376
  Thanks to @jkowens via \#301.
242
377
  * Allow for custom timestamp columns. Thanks to @mojidabckuu, @jkowens
243
378
  via \#401.
244
-
379
+
245
380
  ### Fixes
246
381
 
247
382
  * Fix ActiveRecord 5 issue coercing boolean values when serializing
@@ -253,7 +388,7 @@
253
388
 
254
389
  * Fix issue where PostgreSQL cannot recognize columns if names
255
390
  include mixed case characters. Thanks to @hugobgranja via \#379.
256
- * Fix an issue for ActiveRecord 5 where serialized fields with
391
+ * Fix an issue for ActiveRecord 5 where serialized fields with
257
392
  default values were not being typecast. Thanks to @whistlerbrk,
258
393
  @jkowens via \#386.
259
394
  * 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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
@@ -6,48 +8,56 @@ version = ENV['AR_VERSION'].to_f
6
8
 
7
9
  mysql2_version = '0.3.0'
8
10
  mysql2_version = '0.4.0' if version >= 4.2
11
+ mysql2_version = '0.5.0' if version >= 6.1
9
12
  sqlite3_version = '1.3.0'
10
- sqlite3_version = '1.4.0' if version >= 5.1
13
+ sqlite3_version = '1.4.0' if version >= 6.0
14
+ pg_version = '0.9'
15
+ pg_version = '1.1' if version >= 6.1
11
16
 
12
17
  group :development, :test do
13
- gem 'rubocop', '~> 0.40.0'
18
+ gem 'rubocop'
14
19
  gem 'rake'
15
20
  end
16
21
 
17
22
  # Database Adapters
18
23
  platforms :ruby do
19
24
  gem "mysql2", "~> #{mysql2_version}"
20
- gem "pg", "~> 0.9"
25
+ gem "pg", "~> #{pg_version}"
21
26
  gem "sqlite3", "~> #{sqlite3_version}"
22
- gem "seamless_database_pool", "~> 1.0.20"
27
+ # seamless_database_pool requires Ruby ~> 2.0
28
+ gem "seamless_database_pool", "~> 1.0.20" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')
29
+ gem "trilogy" if version >= 6.0
30
+ if version >= 6.0 && version <= 7.0
31
+ gem "activerecord-trilogy-adapter"
32
+ end
23
33
  end
24
34
 
25
35
  platforms :jruby do
26
36
  gem "jdbc-mysql"
27
37
  gem "jdbc-postgres"
28
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3"
29
- gem "activerecord-jdbcmysql-adapter", "~> 1.3"
30
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3"
38
+ gem "activerecord-jdbcsqlite3-adapter"
39
+ gem "activerecord-jdbcmysql-adapter"
40
+ gem "activerecord-jdbcpostgresql-adapter"
31
41
  end
32
42
 
33
43
  # Support libs
34
- gem "factory_bot"
44
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0")
45
+ gem "factory_bot"
46
+ else
47
+ gem "factory_bot", "~> 5", "< 6.4.5"
48
+ end
35
49
  gem "timecop"
36
50
  gem "chronic"
37
- gem "mocha", "~> 1.3.0"
51
+ gem "mocha", "~> 2.1.0"
38
52
 
39
53
  # Debugging
40
54
  platforms :jruby do
41
55
  gem "ruby-debug", "= 0.10.4"
42
56
  end
43
57
 
44
- platforms :mri_19 do
45
- gem "debugger"
46
- end
47
-
48
58
  platforms :ruby do
49
59
  gem "pry-byebug"
50
- gem "rb-readline"
60
+ gem "pry", "~> 0.14.0"
51
61
  end
52
62
 
53
63
  if version >= 4.0