activerecord-import 0.14.1 → 1.4.1

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 (131) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yaml +107 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +74 -8
  5. data/Brewfile +3 -1
  6. data/CHANGELOG.md +448 -2
  7. data/Gemfile +26 -19
  8. data/LICENSE +21 -56
  9. data/README.markdown +568 -32
  10. data/Rakefile +5 -1
  11. data/activerecord-import.gemspec +8 -7
  12. data/benchmarks/README +2 -2
  13. data/benchmarks/benchmark.rb +8 -1
  14. data/benchmarks/lib/base.rb +2 -0
  15. data/benchmarks/lib/cli_parser.rb +5 -2
  16. data/benchmarks/lib/float.rb +2 -0
  17. data/benchmarks/lib/mysql2_benchmark.rb +2 -0
  18. data/benchmarks/lib/output_to_csv.rb +2 -0
  19. data/benchmarks/lib/output_to_html.rb +4 -2
  20. data/benchmarks/models/test_innodb.rb +2 -0
  21. data/benchmarks/models/test_memory.rb +2 -0
  22. data/benchmarks/models/test_myisam.rb +2 -0
  23. data/benchmarks/schema/{mysql_schema.rb → mysql2_schema.rb} +2 -0
  24. data/gemfiles/4.2.gemfile +4 -3
  25. data/gemfiles/5.0.gemfile +4 -3
  26. data/gemfiles/5.1.gemfile +4 -0
  27. data/gemfiles/5.2.gemfile +4 -0
  28. data/gemfiles/6.0.gemfile +4 -0
  29. data/gemfiles/6.1.gemfile +4 -0
  30. data/gemfiles/7.0.gemfile +4 -0
  31. data/lib/activerecord-import/active_record/adapters/abstract_adapter.rb +2 -0
  32. data/lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb +6 -4
  33. data/lib/activerecord-import/active_record/adapters/jdbcpostgresql_adapter.rb +2 -0
  34. data/lib/activerecord-import/active_record/adapters/jdbcsqlite3_adapter.rb +8 -0
  35. data/lib/activerecord-import/active_record/adapters/mysql2_adapter.rb +2 -0
  36. data/lib/activerecord-import/active_record/adapters/postgresql_adapter.rb +2 -0
  37. data/lib/activerecord-import/active_record/adapters/seamless_database_pool_adapter.rb +2 -0
  38. data/lib/activerecord-import/active_record/adapters/sqlite3_adapter.rb +2 -0
  39. data/lib/activerecord-import/adapters/abstract_adapter.rb +12 -16
  40. data/lib/activerecord-import/adapters/em_mysql2_adapter.rb +2 -0
  41. data/lib/activerecord-import/adapters/mysql2_adapter.rb +2 -0
  42. data/lib/activerecord-import/adapters/mysql_adapter.rb +35 -18
  43. data/lib/activerecord-import/adapters/postgresql_adapter.rb +107 -28
  44. data/lib/activerecord-import/adapters/sqlite3_adapter.rb +141 -18
  45. data/lib/activerecord-import/base.rb +15 -8
  46. data/lib/activerecord-import/import.rb +642 -178
  47. data/lib/activerecord-import/mysql2.rb +2 -0
  48. data/lib/activerecord-import/postgresql.rb +2 -0
  49. data/lib/activerecord-import/sqlite3.rb +2 -0
  50. data/lib/activerecord-import/synchronize.rb +5 -3
  51. data/lib/activerecord-import/value_sets_parser.rb +29 -3
  52. data/lib/activerecord-import/version.rb +3 -1
  53. data/lib/activerecord-import.rb +5 -16
  54. data/test/adapters/jdbcmysql.rb +2 -0
  55. data/test/adapters/jdbcpostgresql.rb +2 -0
  56. data/test/adapters/jdbcsqlite3.rb +3 -0
  57. data/test/adapters/makara_postgis.rb +3 -0
  58. data/test/adapters/mysql2.rb +2 -0
  59. data/test/adapters/mysql2_makara.rb +2 -0
  60. data/test/adapters/mysql2spatial.rb +2 -0
  61. data/test/adapters/postgis.rb +2 -0
  62. data/test/adapters/postgresql.rb +2 -0
  63. data/test/adapters/postgresql_makara.rb +2 -0
  64. data/test/adapters/seamless_database_pool.rb +2 -0
  65. data/test/adapters/spatialite.rb +2 -0
  66. data/test/adapters/sqlite3.rb +2 -0
  67. data/test/{travis → github}/database.yml +7 -1
  68. data/test/import_test.rb +498 -32
  69. data/test/jdbcmysql/import_test.rb +2 -1
  70. data/test/jdbcpostgresql/import_test.rb +2 -1
  71. data/test/jdbcsqlite3/import_test.rb +6 -0
  72. data/test/makara_postgis/import_test.rb +10 -0
  73. data/test/models/account.rb +5 -0
  74. data/test/models/alarm.rb +4 -0
  75. data/test/models/animal.rb +8 -0
  76. data/test/models/bike_maker.rb +9 -0
  77. data/test/models/book.rb +4 -0
  78. data/test/models/car.rb +5 -0
  79. data/test/models/card.rb +5 -0
  80. data/test/models/chapter.rb +2 -0
  81. data/test/models/customer.rb +8 -0
  82. data/test/models/deck.rb +8 -0
  83. data/test/models/dictionary.rb +6 -0
  84. data/test/models/discount.rb +2 -0
  85. data/test/models/end_note.rb +2 -0
  86. data/test/models/group.rb +2 -0
  87. data/test/models/order.rb +8 -0
  88. data/test/models/playing_card.rb +4 -0
  89. data/test/models/promotion.rb +2 -0
  90. data/test/models/question.rb +2 -0
  91. data/test/models/rule.rb +2 -0
  92. data/test/models/tag.rb +7 -0
  93. data/test/models/tag_alias.rb +5 -0
  94. data/test/models/topic.rb +16 -0
  95. data/test/models/user.rb +5 -0
  96. data/test/models/user_token.rb +6 -0
  97. data/test/models/vendor.rb +9 -0
  98. data/test/models/widget.rb +18 -0
  99. data/test/mysql2/import_test.rb +2 -0
  100. data/test/mysql2_makara/import_test.rb +2 -0
  101. data/test/mysqlspatial2/import_test.rb +2 -0
  102. data/test/postgis/import_test.rb +6 -0
  103. data/test/postgresql/import_test.rb +2 -4
  104. data/test/schema/generic_schema.rb +88 -3
  105. data/test/schema/jdbcpostgresql_schema.rb +3 -0
  106. data/test/schema/mysql2_schema.rb +21 -0
  107. data/test/schema/postgis_schema.rb +3 -0
  108. data/test/schema/postgresql_schema.rb +63 -0
  109. data/test/schema/sqlite3_schema.rb +15 -0
  110. data/test/schema/version.rb +2 -0
  111. data/test/sqlite3/import_test.rb +4 -50
  112. data/test/support/active_support/test_case_extensions.rb +8 -1
  113. data/test/support/assertions.rb +2 -0
  114. data/test/support/factories.rb +17 -8
  115. data/test/support/generate.rb +10 -8
  116. data/test/support/mysql/import_examples.rb +17 -3
  117. data/test/support/postgresql/import_examples.rb +442 -9
  118. data/test/support/shared_examples/on_duplicate_key_ignore.rb +45 -0
  119. data/test/support/shared_examples/on_duplicate_key_update.rb +278 -1
  120. data/test/support/shared_examples/recursive_import.rb +137 -12
  121. data/test/support/sqlite3/import_examples.rb +232 -0
  122. data/test/synchronize_test.rb +10 -0
  123. data/test/test_helper.rb +44 -3
  124. data/test/value_sets_bytes_parser_test.rb +15 -2
  125. data/test/value_sets_records_parser_test.rb +2 -0
  126. metadata +74 -22
  127. data/.travis.yml +0 -52
  128. data/gemfiles/3.2.gemfile +0 -3
  129. data/gemfiles/4.0.gemfile +0 -3
  130. data/gemfiles/4.1.gemfile +0 -3
  131. data/test/schema/mysql_schema.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e0eab7d65f5982398dc619a9b74658f8686fca73
4
- data.tar.gz: e2eee39f139a44acf97c11f84a834c70e1833418
2
+ SHA256:
3
+ metadata.gz: 1b9c717d31cf5a4012568c9d8497947466408be7fef5610fba9143f7a911ed7c
4
+ data.tar.gz: 925bc5f645152eeb09f9583e9d50b9be67c4bfa8049c303571f82649262e4d5b
5
5
  SHA512:
6
- metadata.gz: 4b12aea6f47a5f45920c58a227a1f62f445f9fb7f33e7226c17c1c3c0bfc0d680bac38d24342bcb3aa847f46c15cddfa1a8f10cc9e946ca0ba52e0ea43afced7
7
- data.tar.gz: 7ebeae0718cc45a693d986db6f544eadad3c10dcff580403634afbbcd87074cca999a67cf960ed5bb0b438d77737cf09154b88ff701b1068c70cd3a4586a46c7
6
+ metadata.gz: 409d66e4d4e6e9ac31940cea097837d76c93cbeb4b95461323afc6a5f2ace736f945705e5ef33f2a851bb92c13c27e19ffbc14c7e776a0366f1d76091cafd51f
7
+ data.tar.gz: 6a0eaa48b85f7b1863dfb2b04c3c193a5e7e1108084556ba1b25fa303bccb40f62dd706ec8d4b5c3394239f167eb1807dfff4fe292edc1e4ad550719a9a63446
@@ -0,0 +1,107 @@
1
+ name: Test
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ services:
6
+ postgres:
7
+ image: postgis/postgis:10-2.5
8
+ env:
9
+ POSTGRES_USER: postgres
10
+ POSTGRES_PASSWORD: postgres
11
+ ports:
12
+ - 5432:5432
13
+ # Set health checks to wait until postgres has started
14
+ options: >-
15
+ --health-cmd pg_isready
16
+ --health-interval 10s
17
+ --health-timeout 5s
18
+ --health-retries 5
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ ruby:
23
+ - 3.1
24
+ env:
25
+ - AR_VERSION: '7.0'
26
+ RUBYOPT: --enable-frozen-string-literal
27
+ - AR_VERSION: 6.1
28
+ RUBYOPT: --enable-frozen-string-literal
29
+ include:
30
+ - ruby: '3.0'
31
+ env:
32
+ AR_VERSION: '7.0'
33
+ - ruby: '3.0'
34
+ env:
35
+ AR_VERSION: 6.1
36
+ - ruby: 2.7
37
+ env:
38
+ AR_VERSION: '7.0'
39
+ - ruby: 2.7
40
+ env:
41
+ AR_VERSION: 6.1
42
+ - ruby: 2.7
43
+ env:
44
+ AR_VERSION: '6.0'
45
+ - ruby: 2.6
46
+ env:
47
+ AR_VERSION: 5.2
48
+ - ruby: 2.6
49
+ env:
50
+ AR_VERSION: 5.1
51
+ - ruby: 2.4
52
+ env:
53
+ AR_VERSION: '5.0'
54
+ - ruby: 2.4
55
+ env:
56
+ AR_VERSION: 4.2
57
+ runs-on: ubuntu-latest
58
+ env:
59
+ AR_VERSION: ${{ matrix.env.AR_VERSION }}
60
+ DB_DATABASE: activerecord_import_test
61
+ steps:
62
+ - uses: actions/checkout@v2
63
+ - uses: ruby/setup-ruby@v1
64
+ with:
65
+ ruby-version: ${{ matrix.ruby }}
66
+ bundler-cache: true
67
+ - name: Set up databases
68
+ run: |
69
+ sudo /etc/init.d/mysql start
70
+ mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }} CHARACTER SET utf8 COLLATE utf8_general_ci;' -u root -proot
71
+ psql -h localhost -U postgres -c 'create database ${{ env.DB_DATABASE }};'
72
+ psql -h localhost -U postgres -d ${{ env.DB_DATABASE }} -c 'create extension if not exists hstore;'
73
+ psql -h localhost -U postgres -c 'create extension if not exists postgis;'
74
+ psql -h localhost -U postgres -c 'create extension if not exists "uuid-ossp";'
75
+ cp test/github/database.yml test/database.yml
76
+ env:
77
+ PGPASSWORD: postgres
78
+ - name: Run tests with mysql2
79
+ run: |
80
+ bundle exec rake test:mysql2
81
+ bundle exec rake test:mysql2_makara
82
+ bundle exec rake test:mysql2spatial
83
+ - name: Run tests with postgresql
84
+ run: |
85
+ bundle exec rake test:postgis
86
+ bundle exec rake test:postgresql
87
+ bundle exec rake test:postgresql_makara
88
+ - name: Run tests with seamless_database_pool
89
+ run: |
90
+ bundle exec rake test:seamless_database_pool
91
+ if: ${{ matrix.ruby < '3.0' }}
92
+ - name: Run tests with sqlite
93
+ run: |
94
+ bundle exec rake test:spatialite
95
+ bundle exec rake test:sqlite3
96
+ lint:
97
+ runs-on: ubuntu-latest
98
+ env:
99
+ AR_VERSION: '7.0'
100
+ steps:
101
+ - uses: actions/checkout@v2
102
+ - uses: ruby/setup-ruby@v1
103
+ with:
104
+ ruby-version: 2.7
105
+ bundler-cache: true
106
+ - name: Run Rubocop
107
+ run: bundle exec rubocop
data/.gitignore CHANGED
@@ -24,6 +24,7 @@ pkg
24
24
  log/*.log
25
25
  test.db
26
26
  test/database.yml
27
+ benchmarks/log/
27
28
 
28
29
  .ruby-*
29
30
  .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/AlignArguments:
70
+ Enabled: false
71
+
72
+ Layout/AlignParameters:
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/IndentHeredoc:
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/UncommunicativeMethodParamName:
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/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,8 +1,455 @@
1
+ ## Changes in 1.4.1
2
+
3
+ ### Fixes
4
+
5
+ * Fix importing models that have required belongs_to associations and use composite primary keys. Thanks to @thoughtbot-summer vi \##783.
6
+
7
+ ## Changes in 1.4.0
8
+
9
+ ### New Features
10
+
11
+ * Enable compatibility with frozen string literals. Thanks to @desheikh via \##760.
12
+
13
+ ## Changes in 1.3.0
14
+
15
+ ### Fixes
16
+
17
+ * Ensure correct timestamp values are returned for models after insert. Thanks to @kos1kov via \##756.
18
+ * Restore database_version method to public scope. Thanks to @beauraF via \##753.
19
+
20
+ ### New Features
21
+
22
+ * Add support for ActiveRecord 7.0. Thanks to @nickhammond, @ryanwood, @jkowens via \##749 and \##752.
23
+ * Add support for compound foreign keys. Thanks to @Uladzimiro via \##750.
24
+ * Add support for :recursive combined with on_duplicate_key_update: :all. Thanks to @deathwish via \##746.
25
+
26
+ ## Changes in 1.2.0
27
+
28
+ ### Fixes
29
+
30
+ * Update JDBC MySQL adapter to use mysql2 connection adapter. Thanks to @terencechow via \##744.
31
+ * Fix importing STI models with ActiveRecord 6. Thanks to @clemens1483 via \##743.
32
+ * Use polymorphic_name instead of base_class.name for imports. Thanks to @kmhajjar via \##741.
33
+ * Fix compatibility issue with composite primary keys. Thanks to @dlanileonardo via \##737.
34
+ * Prevent double validation of associations on recursive import.
35
+
36
+ ## Changes in 1.1.0
37
+
38
+ ### New Features
39
+
40
+ * Add batch progress reporting. Thanks to @gee-forr via \##729.
41
+
42
+ ## Changes in 1.0.8
43
+
44
+ ### Fixes
45
+
46
+ * Use correct method for clearing query cache. Thanks to @EtienneDepaulis via \##719.
47
+
48
+ ## Changes in 1.0.7
49
+
50
+ ### New Features
51
+
52
+ * Use @@max_allowed_packet session variable instead of querying SHOW VARIABLES. Thanks to @diclophis via \#706.
53
+ * 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.
54
+
55
+ ### Fixes
56
+
57
+ * Prevent mass-assignment errors in Rails strict mode. Thanks to @diclophis via \##709.
58
+
59
+ ## Changes in 1.0.6
60
+
61
+ ### Fixes
62
+
63
+ * Handle after_initialize callbacks. Thanks to @AhMohsen46 via \#691 and
64
+ \#692.
65
+ * Fix regression introduced in 1.0.4. Explicitly allow adapters to
66
+ support on duplicate key update. Thanks to @dsobiera, @jkowens via \#696.
67
+
68
+ ## Changes in 1.0.5
69
+
70
+ ### Fixes
71
+
72
+ * Allow serialized attributes to be returned from import. Thanks to @timanovsky, @jkowens via \#660.
73
+ * Return ActiveRecord::Connection from
74
+ ActiveRecord::Base#establish_connection. Thanks to @reverentF via
75
+ \#663.
76
+ * Support PostgreSQL array. Thanks to @ujihisa via \#669.
77
+ * Skip loading association ids when column changed. Thanks to @Aristat
78
+ via \#673.
79
+
80
+ ## Changes in 1.0.4
81
+
82
+ ### Fixes
83
+
84
+ * Use prepend pattern for ActiveRecord::Base#establish_connection patching. Thanks to @dombesz via \#648.
85
+ * Fix NoMethodError when using PostgreSQL ENUM types. Thanks to @sebcoetzee via \#651.
86
+ * Fix issue updating optimistic lock in Postgres. Thanks to @timanovsky
87
+ via \#656.
88
+
89
+ ## Changes in 1.0.3
90
+
91
+ ### New Features
92
+
93
+ * Add support for ActiveRecord 6.1.0.alpha. Thanks to @imtayadeway via
94
+ \#642.
95
+
96
+ ### Fixes
97
+
98
+ * Return an empty array for results instead of nil when importing empty
99
+ array. Thanks to @gyfis via \#636.
100
+
101
+ ## Changes in 1.0.2
102
+
103
+ ### New Features
104
+
105
+ * Add support for CockroachDB adapter. Thanks to @willie via \#605.
106
+ * Add support for ActiveRecord 6.0.0.rc1. Thanks to @madeindjs, @bill-filler,
107
+ @jkowens via \#619, \#623.
108
+
109
+ ### Fixes
110
+
111
+ * Fixes NoMethodError when attempting to use nil logger. Thanks to @MattMecel,
112
+ @khiav22357.
113
+ * Fix issue validating STI models. Thanks to @thejbsmith, @jkowens via
114
+ \#626.
115
+
116
+ ## Changes in 1.0.1
117
+
118
+ ### Fixes
119
+
120
+ * Raise an error with a helpful message if array of values exceeds the number of
121
+ columns for a table. Thanks to @golddranks via \#589.
122
+ * Properly check if model responds to import before creating alias.
123
+ Thanks to @jcw- via \#591.
124
+ * No longer pass :returning option to child associations on recursive
125
+ import. Thanks to @dmitriy-kiriyenko via \#595.
126
+ * Fix import issue for models with Postgresql json/jsonb fields. Thanks
127
+ to @stokarenko via \#594.
128
+ * Fix issue importing models with timestamps that contain timezone
129
+ information. Thanks to @dekaikiwi, @jkowens via \#598.
130
+ * Ignore :no_returning when using :recursive option. Thanks to @dgollahon, @jkowens
131
+ via \#599.
132
+
133
+ ## Changes in 1.0.0
134
+
135
+ ### New Features
136
+
137
+ * Move ActiveRecord::Dirty changes to previous_changes after import.
138
+ Thanks to @stokarenko via \#584.
139
+
140
+ ### Breaking Changes
141
+
142
+ * Previously :on_duplicate_key_update was enabled by default for MySQL.
143
+ The update timestamp columns (updated_at, updated_on) would be updated
144
+ on duplicate key. This was behavior is inconsistent with the other database
145
+ adapters and could also be considered surprising. Going forward it must
146
+ be explicitly enabled. See \#548.
147
+
148
+ ## Changes in 0.28.2
149
+
150
+ ### Fixes
151
+
152
+ * Fix issue where validations where not working in certain scenarios.
153
+ Thanks to @CASIXx1 via \#579.
154
+
155
+ ## Changes in 0.28.1
156
+
157
+ ### Fixes
158
+
159
+ * Fix issue where ActiveRecord presence validations were being mutated.
160
+ Limited custom presence validation to bulk imports.
161
+
162
+ ## Changes in 0.28.0
163
+
164
+ ### New Features
165
+
166
+ * Allow updated timestamps to be manually set.Thanks to @Rob117, @jkowens via \#570.
167
+
168
+ ### Fixes
169
+
170
+ * Fix validating presence of belongs_to associations. Existence
171
+ of the parent record is not validated, but the foreign key field
172
+ cannot be empty. Thanks to @Rob117, @jkowens via \#575.
173
+
174
+ ## Changes in 0.27.0
175
+
176
+ ### New Features
177
+
178
+ * Add "secret" option validate_uniqueness to enable uniqueness
179
+ validators when validating import. This is not a recommended
180
+ approach (See #228), but is being added back in for projects
181
+ that depended on this feature. Thanks to @jkowens via \#554.
182
+
183
+ ## Changes in 0.26.0
184
+
185
+ ### New Features
186
+
187
+ * Add on_duplicate_key_update for SQLite. Thanks to @jkowens via \#542.
188
+ * Add option to update all fields on_duplicate_key_update. Thanks to @aimerald, @jkowens via \#543.
189
+
190
+ ### Fixes
191
+
192
+ * Handle deeply frozen options hashes. Thanks to @jturkel via \#546.
193
+ * Switch from FactoryGirl to FactoryBot. Thanks to @koic via \#547.
194
+ * Allow import to work with ProxySQL. Thanks to @GregFarrell via \#550.
195
+
196
+ ## Changes in 0.25.0
197
+
198
+ ### New Features
199
+
200
+ * Add support for makara_postgis adapter. Thanks to @chadwilken via \#527.
201
+ * Skip validating presence of belongs_to associations. Thanks to @Sohair63, @naiyt, @jkowens via \#528.
202
+
203
+ ### Fixes
204
+
205
+ * Add missing require for ActiveSupport.on_load. Thanks to @onk via \#529.
206
+ * Support setting attribute values in before_validation callbacks.
207
+ Thanks to @SirRawlins, @jkowens via \#531.
208
+ * Ignore virtual columns. Thanks to @dbourguignon, @jkowens via \#530.
209
+
210
+ ## Changes in 0.24.0
211
+
212
+ ### Fixes
213
+
214
+ * Use the association primary key when importing. Thanks to @dpogue via \#512.
215
+ * Allow association ids to be updated. Thanks to @Aristat via \#515.
216
+
217
+ ## Changes in 0.23.0
218
+
219
+ ### New Features
220
+
221
+ * Rename `import` method to `bulk_import` and alias to `import`. Thanks
222
+ to @itay-grudev, @jkowens via \#498.
223
+ * Increment lock_version on duplicate key update. Thanks to @aimerald
224
+ via \#500.
225
+
226
+ ### Fixes
227
+
228
+ * Fix import_without_validations_or_callbacks exception if array is empty.
229
+ Thanks to @doloopwhile via \#508.
230
+
231
+ ## Changes in 0.22.0
232
+
233
+ ### New Features
234
+
235
+ * Add support for importing hashes thru a has many association. Thanks
236
+ to @jkowens via \#483.
237
+
238
+ ### Fixes
239
+
240
+ * Fix validation logic for recursive import. For those on Rails 5.0 and 5.1,
241
+ this change requires models with polymorphic associations to specify the `inverse_of`
242
+ argument (See issue #495). Thanks to @eric-simonton-sama, @jkowens via
243
+ \#489.
244
+
245
+ ## Changes in 0.21.0
246
+
247
+ ### New Features
248
+
249
+ * Allow SQL subqueries (objects that respond to .to_sql) to be passed as values. Thanks
250
+ to @jalada, @jkowens via \#471
251
+ * Raise an ArgumentError when importing an array of hashes if any of the
252
+ hash objects have different keys. Thanks to @mbell697 via \#465.
253
+
254
+ ### Fixes
255
+
256
+ * Fix issue loading incorrect foreign key value when syncing belongs_to
257
+ associations with custom foreign key columns. Thanks to @marcgreenstock, @jkowens via \#470.
258
+ * Fix issue importing models with polymorphic belongs_to associations.
259
+ Thanks to @zorab47, @jkowens via \#476.
260
+ * Fix issue importing STI models with ActiveRecord 4.0. Thanks to
261
+ @kazuki-st, @jkowens via \#478.
262
+
263
+ ## Changes in 0.20.2
264
+
265
+ ### Fixes
266
+
267
+ * Unscope model when synchronizing with database. Thanks to @indigoviolet via \#455.
268
+
269
+ ## Changes in 0.20.1
270
+
271
+ ### Fixes
272
+
273
+ * Prevent :on_duplicate_key_update args from being modified. Thanks to @joshuamcginnis, @jkowens via \#451.
274
+
275
+ ## Changes in 0.20.0
276
+
277
+ ### New Features
278
+
279
+ * Allow returning columns to be specified for PostgreSQL. Thanks to
280
+ @tjwp via \#433.
281
+
282
+ ### Fixes
283
+
284
+ * Fixes an issue when bypassing uniqueness validators. Thanks to @vmaxv via \#444.
285
+ * For AR < 4.2, prevent type casting for binary columns on Postgresql. Thanks to @mwalsher via \#446.
286
+ * Fix issue logging class name on import. Thanks to @sophylee, @jkowens via \#447.
287
+ * Copy belongs_to association id to foreign key column before importing. Thanks to @jkowens via \#448.
288
+ * Reset model instance on validate. Thanks to @vmaxv via \#449.
289
+
290
+ ## Changes in 0.19.1
291
+
292
+ ### Fixes
293
+
294
+ * Fix a regression where models weren't properly being marked clean. Thanks to @tjwp via \#434.
295
+ * Raise ActiveRecord::Import::ValueSetTooLargeError when a record being inserted exceeds the
296
+ `max_allowed_packet` for MySQL. Thanks to @saizai, @jkowens via \#437.
297
+ * Fix issue concatenating column names array with primary key. Thanks to @keeguon via \#440.
298
+
299
+ ## Changes in 0.19.0
300
+
301
+ ### New Features
302
+
303
+ * For PostgreSQL, add option to set WHERE condition in conflict_action. Thanks to
304
+ @Saidbek via \#423.
305
+
306
+ ### Fixes
307
+
308
+ * Fix issue importing saved records with serialized fields. Thanks to
309
+ @Andreis13, @jkowens via \#425.
310
+ * Fix issue importing records that have columns defined with default values
311
+ that are functions or expressions. Thanks to @Andreis13, @jkowens via \#428.
312
+
313
+ ## Changes in 0.18.3
314
+
315
+ ### Fixes
316
+
317
+ * Set models new_record attribute to false when importing with
318
+ :on_duplicate_key_ignore. Thanks to @nijikon, @jkowens via \#416.
319
+
320
+ ## Changes in 0.18.2
321
+
322
+ ### Fixes
323
+
324
+ * Enable custom validate callbacks when validating import. Thanks to @afn via \#410.
325
+ * Prevent wrong IDs being set on models when using :on_duplicate_key_ignore.
326
+ Thanks to @afn, @jkowens via \#412.
327
+
328
+ ## Changes in 0.18.1
329
+
330
+ ### Fixes
331
+
332
+ * Fix to enable validation callbacks (before_validation,
333
+ after_validation). Thanks to @sinsoku, @jkowens via \#406.
334
+
335
+ ## Changes in 0.18.0
336
+
337
+ ### New Features
338
+
339
+ * Uniqueness validation is bypassed when validating models since
340
+ it cannot be guaranteed if there are duplicates in a batch.
341
+ Thanks to @jkowens via \#301.
342
+ * Allow for custom timestamp columns. Thanks to @mojidabckuu, @jkowens
343
+ via \#401.
344
+
345
+ ### Fixes
346
+
347
+ * Fix ActiveRecord 5 issue coercing boolean values when serializing
348
+ for the database. Thanks to @rjrobinson, @jkowens via \#403.
349
+
350
+ ## Changes in 0.17.2
351
+
352
+ ### Fixes
353
+
354
+ * Fix issue where PostgreSQL cannot recognize columns if names
355
+ include mixed case characters. Thanks to @hugobgranja via \#379.
356
+ * Fix an issue for ActiveRecord 5 where serialized fields with
357
+ default values were not being typecast. Thanks to @whistlerbrk,
358
+ @jkowens via \#386.
359
+ * Add option :force_single_insert for MySQL to make sure a single
360
+ insert is attempted instead of performing multiple inserts based
361
+ on max_allowed_packet. Thanks to @mtparet via \#387.
362
+
363
+ ## Changes in 0.17.1
364
+
365
+ ### Fixes
366
+
367
+ * Along with setting id on models for adapters that support it,
368
+ add created_at and updated_at timestamps. Thanks to @jacob-carlborg
369
+ via \#364.
370
+ * Properly set returned ids when using composite_primary_keys.
371
+ Thanks to @guigs, @jkowens via \#371.
372
+
373
+ ## Changes in 0.17.0
374
+
375
+ ### New Features
376
+
377
+ * Add support for composite_primary_keys gem. Thanks to @jkowens
378
+ via \#350.
379
+ * Add support for importing an array of hashes. Thanks to @jkowens
380
+ via \#352.
381
+ * Add JDBC SQLite3 support. Thanks to @jkowens via \#356.
382
+
383
+ ### Fixes
384
+
385
+ * Remove support for SQLite recursive imports. See \#351.
386
+ * Improve import speed for Rails 5. Thanks to @ranchodeluxe, @jkowens
387
+ via \#359.
388
+
389
+ ## Changes in 0.16.2
390
+
391
+ ### Fixes
392
+
393
+ * Fixes issue clearing query cache on wrong connection when using
394
+ multiple databases. Thanks to @KentoMoriwaki via \#337
395
+ * Raises an ArgumentError on incorrect usage of nested arrays. Thanks
396
+ to @Nitrodist via \#340
397
+ * Fixes issue that prevented uuid primary keys from being set manually.
398
+ Thanks to @Dclusin-og, @jkowens via \#342
399
+
400
+ ## Changes in 0.16.1
401
+
402
+ ### Fixes
403
+
404
+ * Fixes issue with missing error messages on failed instances when
405
+ importing using arrays of columns and values. Thanks to @Fivell via \#332
406
+ * Update so SQLite only return ids if table has a primary key field via \#333
407
+
408
+
409
+ ## Changes in 0.16.0
410
+
411
+ ### New Features
412
+
413
+ * Add partial index upsert support for PostgreSQL. Thanks to @luislew via \#305
414
+ * Add UUID primary key support for PostgreSQL. Thanks to @jkowens via
415
+ \#312
416
+ * Add store accessor support for JSON, JSON, and HSTORE data types.
417
+ Thanks to @jkowens via \#322
418
+ * Log warning if database does not support :on_duplicate_key_update.
419
+ Thanks to @jkowens via \#324
420
+ * Add option :on_duplicate_key_ignore for MySQL and SQLite. Thanks to
421
+ @jkowens via \#326
422
+
423
+ ### Fixes
424
+
425
+ * Fixes issue with recursive import using same primary key for all models.
426
+ Thanks to @chopraanmol1 via \#309
427
+ * Fixes issue importing from STI subclass with polymorphic associations.
428
+ Thanks to @JNajera via \#314
429
+ * Fixes issue setting returned IDs to wrong models when some fail validation. Also fixes issue with SQLite returning wrong IDs. Thanks to @mizukami234 via \#315
430
+
431
+
432
+ ## Changes in 0.15.0
433
+
434
+ ### New Features
435
+
436
+ * An ArgumentError is now raised if when no `conflict_target` or `conflict_name` is provided or can be determined when using the `on_duplicate_key_update` option for PostgreSQL. Thanks to @jkowens via \#290
437
+ * Support for Rails 5.0 final release for all except the JDBC driver which is not yet updated to support Rails 5.0
438
+
439
+ ### Fixes
440
+
441
+ * activerecord-import no longer modifies a value array inside of the given values array when called with `import(columns, values)`. Thanks to @jkowens via \#291
442
+
443
+ ### Misc
444
+
445
+ * `raise_error` is used to raise errors for ActiveRecord 5.0. Thanks to @couragecourag via \#294 `raise_record_invalid` has been
446
+
447
+
1
448
  ## Changes in 0.14.1
2
449
 
3
450
  ### Fixes
4
451
 
5
- * JRuby/JDBCDriver with PostgreSQL will no longer raise a JDBCDriver error when using the :no_returning boolean option. Thanks to @jkowens via \#287
452
+ * JRuby/JDBCDriver with PostgreSQL will no longer raise a JDBCDriver error when using the :no_returning boolean option. Thanks to @jkowens via \#287
6
453
 
7
454
  ## Changes in 0.14.0
8
455
 
@@ -26,7 +473,6 @@
26
473
  * Code cleanup, removal of deprecated `alias_method_chain`. Thanks to @codeodor via \#271
27
474
 
28
475
 
29
-
30
476
  ## Changes in 0.13.0
31
477
 
32
478
  ### New Features