activerecord-import 0.25.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +5 -5
  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 +232 -2
  8. data/Dockerfile +23 -0
  9. data/Gemfile +26 -14
  10. data/LICENSE +21 -56
  11. data/README.markdown +612 -21
  12. data/Rakefile +4 -1
  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 -0
  31. data/gemfiles/6.1.gemfile +4 -0
  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 +15 -6
  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 +34 -29
  47. data/lib/activerecord-import/adapters/postgresql_adapter.rb +74 -55
  48. data/lib/activerecord-import/adapters/sqlite3_adapter.rb +138 -13
  49. data/lib/activerecord-import/adapters/trilogy_adapter.rb +7 -0
  50. data/lib/activerecord-import/base.rb +11 -2
  51. data/lib/activerecord-import/import.rb +290 -114
  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 +4 -2
  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 +151 -8
  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 +3 -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 +49 -0
  119. data/test/schema/sqlite3_schema.rb +15 -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 +10 -8
  125. data/test/support/generate.rb +10 -8
  126. data/test/support/mysql/import_examples.rb +2 -1
  127. data/test/support/postgresql/import_examples.rb +152 -3
  128. data/test/support/shared_examples/on_duplicate_key_ignore.rb +2 -0
  129. data/test/support/shared_examples/on_duplicate_key_update.rb +122 -9
  130. data/test/support/shared_examples/recursive_import.rb +128 -2
  131. data/test/support/sqlite3/import_examples.rb +191 -26
  132. data/test/synchronize_test.rb +2 -0
  133. data/test/test_helper.rb +34 -7
  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 +46 -16
  138. data/.travis.yml +0 -71
  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
- SHA1:
3
- metadata.gz: 26224d6c0d4c23f3edaf1faea68466f18c03fbbc
4
- data.tar.gz: 55107f77211b86e3be77b287d224e488dbb280ac
2
+ SHA256:
3
+ metadata.gz: 5aeed63fcbc9ad647ab901931265d2765baf5d0e5a1e9d2cf2c68af32dd5e1be
4
+ data.tar.gz: 47480cc7244aada4bc69ba28043e8ab85ae1cece4420db4453400425a5773126
5
5
  SHA512:
6
- metadata.gz: c0815961332178cf2858b39663f1d9f6ef3d61985cd4cb528cef410714e4bf07c354515b5e06124ad4bb5c7e57e7a179c48d7fb5c5e28886bc9e30c4399e82c9
7
- data.tar.gz: df5e8ccd8a658d4981cd26167e09fa8c5e0425c58e4397c48e6f7721221d1de3cc4c6cdf903e3330f07cf6a74b93214cd11cca977f6d75cf6e8b43409807c23b
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,233 @@
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
+
136
+ ## Changes in 1.0.2
137
+
138
+ ### New Features
139
+
140
+ * Add support for CockroachDB adapter. Thanks to @willie via \#605.
141
+ * Add support for ActiveRecord 6.0.0.rc1. Thanks to @madeindjs, @bill-filler,
142
+ @jkowens via \#619, \#623.
143
+
144
+ ### Fixes
145
+
146
+ * Fixes NoMethodError when attempting to use nil logger. Thanks to @MattMecel,
147
+ @khiav22357.
148
+ * Fix issue validating STI models. Thanks to @thejbsmith, @jkowens via
149
+ \#626.
150
+
151
+ ## Changes in 1.0.1
152
+
153
+ ### Fixes
154
+
155
+ * Raise an error with a helpful message if array of values exceeds the number of
156
+ columns for a table. Thanks to @golddranks via \#589.
157
+ * Properly check if model responds to import before creating alias.
158
+ Thanks to @jcw- via \#591.
159
+ * No longer pass :returning option to child associations on recursive
160
+ import. Thanks to @dmitriy-kiriyenko via \#595.
161
+ * Fix import issue for models with Postgresql json/jsonb fields. Thanks
162
+ to @stokarenko via \#594.
163
+ * Fix issue importing models with timestamps that contain timezone
164
+ information. Thanks to @dekaikiwi, @jkowens via \#598.
165
+ * Ignore :no_returning when using :recursive option. Thanks to @dgollahon, @jkowens
166
+ via \#599.
167
+
168
+ ## Changes in 1.0.0
169
+
170
+ ### New Features
171
+
172
+ * Move ActiveRecord::Dirty changes to previous_changes after import.
173
+ Thanks to @stokarenko via \#584.
174
+
175
+ ### Breaking Changes
176
+
177
+ * Previously :on_duplicate_key_update was enabled by default for MySQL.
178
+ The update timestamp columns (updated_at, updated_on) would be updated
179
+ on duplicate key. This was behavior is inconsistent with the other database
180
+ adapters and could also be considered surprising. Going forward it must
181
+ be explicitly enabled. See \#548.
182
+
183
+ ## Changes in 0.28.2
184
+
185
+ ### Fixes
186
+
187
+ * Fix issue where validations where not working in certain scenarios.
188
+ Thanks to @CASIXx1 via \#579.
189
+
190
+ ## Changes in 0.28.1
191
+
192
+ ### Fixes
193
+
194
+ * Fix issue where ActiveRecord presence validations were being mutated.
195
+ Limited custom presence validation to bulk imports.
196
+
197
+ ## Changes in 0.28.0
198
+
199
+ ### New Features
200
+
201
+ * Allow updated timestamps to be manually set.Thanks to @Rob117, @jkowens via \#570.
202
+
203
+ ### Fixes
204
+
205
+ * Fix validating presence of belongs_to associations. Existence
206
+ of the parent record is not validated, but the foreign key field
207
+ cannot be empty. Thanks to @Rob117, @jkowens via \#575.
208
+
209
+ ## Changes in 0.27.0
210
+
211
+ ### New Features
212
+
213
+ * Add "secret" option validate_uniqueness to enable uniqueness
214
+ validators when validating import. This is not a recommended
215
+ approach (See #228), but is being added back in for projects
216
+ that depended on this feature. Thanks to @jkowens via \#554.
217
+
218
+ ## Changes in 0.26.0
219
+
220
+ ### New Features
221
+
222
+ * Add on_duplicate_key_update for SQLite. Thanks to @jkowens via \#542.
223
+ * Add option to update all fields on_duplicate_key_update. Thanks to @aimerald, @jkowens via \#543.
224
+
225
+ ### Fixes
226
+
227
+ * Handle deeply frozen options hashes. Thanks to @jturkel via \#546.
228
+ * Switch from FactoryGirl to FactoryBot. Thanks to @koic via \#547.
229
+ * Allow import to work with ProxySQL. Thanks to @GregFarrell via \#550.
230
+
1
231
  ## Changes in 0.25.0
2
232
 
3
233
  ### New Features
@@ -146,7 +376,7 @@
146
376
  Thanks to @jkowens via \#301.
147
377
  * Allow for custom timestamp columns. Thanks to @mojidabckuu, @jkowens
148
378
  via \#401.
149
-
379
+
150
380
  ### Fixes
151
381
 
152
382
  * Fix ActiveRecord 5 issue coercing boolean values when serializing
@@ -158,7 +388,7 @@
158
388
 
159
389
  * Fix issue where PostgreSQL cannot recognize columns if names
160
390
  include mixed case characters. Thanks to @hugobgranja via \#379.
161
- * Fix an issue for ActiveRecord 5 where serialized fields with
391
+ * Fix an issue for ActiveRecord 5 where serialized fields with
162
392
  default values were not being typecast. Thanks to @whistlerbrk,
163
393
  @jkowens via \#386.
164
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,46 +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
12
+ sqlite3_version = '1.3.0'
13
+ sqlite3_version = '1.4.0' if version >= 6.0
14
+ pg_version = '0.9'
15
+ pg_version = '1.1' if version >= 6.1
9
16
 
10
17
  group :development, :test do
11
- gem 'rubocop', '~> 0.40.0'
18
+ gem 'rubocop'
12
19
  gem 'rake'
13
20
  end
14
21
 
15
22
  # Database Adapters
16
23
  platforms :ruby do
17
24
  gem "mysql2", "~> #{mysql2_version}"
18
- gem "pg", "~> 0.9"
19
- gem "sqlite3", "~> 1.3.10"
20
- gem "seamless_database_pool", "~> 1.0.20"
25
+ gem "pg", "~> #{pg_version}"
26
+ gem "sqlite3", "~> #{sqlite3_version}"
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
21
33
  end
22
34
 
23
35
  platforms :jruby do
24
36
  gem "jdbc-mysql"
25
37
  gem "jdbc-postgres"
26
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3"
27
- gem "activerecord-jdbcmysql-adapter", "~> 1.3"
28
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3"
38
+ gem "activerecord-jdbcsqlite3-adapter"
39
+ gem "activerecord-jdbcmysql-adapter"
40
+ gem "activerecord-jdbcpostgresql-adapter"
29
41
  end
30
42
 
31
43
  # Support libs
32
- gem "factory_girl", "~> 4.2.0"
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
33
49
  gem "timecop"
34
50
  gem "chronic"
35
- gem "mocha", "~> 1.3.0"
51
+ gem "mocha", "~> 2.1.0"
36
52
 
37
53
  # Debugging
38
54
  platforms :jruby do
39
55
  gem "ruby-debug", "= 0.10.4"
40
56
  end
41
57
 
42
- platforms :mri_19 do
43
- gem "debugger"
44
- end
45
-
46
58
  platforms :ruby do
47
59
  gem "pry-byebug"
48
- gem "rb-readline"
60
+ gem "pry", "~> 0.14.0"
49
61
  end
50
62
 
51
63
  if version >= 4.0