activerecord-import 0.10.0 → 1.0.8

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 (118) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +49 -0
  4. data/.rubocop_todo.yml +36 -0
  5. data/.travis.yml +64 -8
  6. data/CHANGELOG.md +475 -0
  7. data/Gemfile +32 -15
  8. data/LICENSE +21 -56
  9. data/README.markdown +564 -35
  10. data/Rakefile +20 -3
  11. data/activerecord-import.gemspec +7 -7
  12. data/benchmarks/README +2 -2
  13. data/benchmarks/benchmark.rb +68 -64
  14. data/benchmarks/lib/base.rb +138 -137
  15. data/benchmarks/lib/cli_parser.rb +107 -103
  16. data/benchmarks/lib/{mysql_benchmark.rb → mysql2_benchmark.rb} +19 -22
  17. data/benchmarks/lib/output_to_csv.rb +5 -4
  18. data/benchmarks/lib/output_to_html.rb +8 -13
  19. data/benchmarks/models/test_innodb.rb +1 -1
  20. data/benchmarks/models/test_memory.rb +1 -1
  21. data/benchmarks/models/test_myisam.rb +1 -1
  22. data/benchmarks/schema/mysql2_schema.rb +16 -0
  23. data/gemfiles/3.2.gemfile +2 -4
  24. data/gemfiles/4.0.gemfile +2 -4
  25. data/gemfiles/4.1.gemfile +2 -4
  26. data/gemfiles/4.2.gemfile +2 -4
  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 +2 -0
  31. data/gemfiles/6.1.gemfile +1 -0
  32. data/lib/activerecord-import/active_record/adapters/jdbcsqlite3_adapter.rb +6 -0
  33. data/lib/activerecord-import/active_record/adapters/sqlite3_adapter.rb +0 -1
  34. data/lib/activerecord-import/adapters/abstract_adapter.rb +23 -17
  35. data/lib/activerecord-import/adapters/mysql_adapter.rb +52 -25
  36. data/lib/activerecord-import/adapters/postgresql_adapter.rb +187 -10
  37. data/lib/activerecord-import/adapters/sqlite3_adapter.rb +148 -17
  38. data/lib/activerecord-import/base.rb +15 -9
  39. data/lib/activerecord-import/import.rb +740 -191
  40. data/lib/activerecord-import/synchronize.rb +21 -21
  41. data/lib/activerecord-import/value_sets_parser.rb +33 -8
  42. data/lib/activerecord-import/version.rb +1 -1
  43. data/lib/activerecord-import.rb +4 -15
  44. data/test/adapters/jdbcsqlite3.rb +1 -0
  45. data/test/adapters/makara_postgis.rb +1 -0
  46. data/test/adapters/mysql2_makara.rb +1 -0
  47. data/test/adapters/mysql2spatial.rb +1 -1
  48. data/test/adapters/postgis.rb +1 -1
  49. data/test/adapters/postgresql.rb +1 -1
  50. data/test/adapters/postgresql_makara.rb +1 -0
  51. data/test/adapters/spatialite.rb +1 -1
  52. data/test/adapters/sqlite3.rb +1 -1
  53. data/test/database.yml.sample +13 -18
  54. data/test/import_test.rb +608 -89
  55. data/test/jdbcmysql/import_test.rb +2 -3
  56. data/test/jdbcpostgresql/import_test.rb +0 -2
  57. data/test/jdbcsqlite3/import_test.rb +4 -0
  58. data/test/makara_postgis/import_test.rb +8 -0
  59. data/test/models/account.rb +3 -0
  60. data/test/models/alarm.rb +2 -0
  61. data/test/models/animal.rb +6 -0
  62. data/test/models/bike_maker.rb +7 -0
  63. data/test/models/book.rb +7 -6
  64. data/test/models/car.rb +3 -0
  65. data/test/models/chapter.rb +2 -2
  66. data/test/models/dictionary.rb +4 -0
  67. data/test/models/discount.rb +3 -0
  68. data/test/models/end_note.rb +2 -2
  69. data/test/models/promotion.rb +3 -0
  70. data/test/models/question.rb +3 -0
  71. data/test/models/rule.rb +3 -0
  72. data/test/models/tag.rb +4 -0
  73. data/test/models/topic.rb +17 -3
  74. data/test/models/user.rb +3 -0
  75. data/test/models/user_token.rb +4 -0
  76. data/test/models/vendor.rb +7 -0
  77. data/test/models/widget.rb +19 -2
  78. data/test/mysql2/import_test.rb +2 -3
  79. data/test/{em_mysql2 → mysql2_makara}/import_test.rb +1 -1
  80. data/test/mysqlspatial2/import_test.rb +2 -2
  81. data/test/postgis/import_test.rb +5 -1
  82. data/test/schema/generic_schema.rb +159 -85
  83. data/test/schema/jdbcpostgresql_schema.rb +1 -0
  84. data/test/schema/mysql2_schema.rb +19 -0
  85. data/test/schema/postgis_schema.rb +1 -0
  86. data/test/schema/postgresql_schema.rb +61 -0
  87. data/test/schema/sqlite3_schema.rb +13 -0
  88. data/test/sqlite3/import_test.rb +2 -50
  89. data/test/support/active_support/test_case_extensions.rb +21 -13
  90. data/test/support/{mysql/assertions.rb → assertions.rb} +20 -2
  91. data/test/support/factories.rb +39 -14
  92. data/test/support/generate.rb +10 -10
  93. data/test/support/mysql/import_examples.rb +49 -98
  94. data/test/support/postgresql/import_examples.rb +535 -57
  95. data/test/support/shared_examples/on_duplicate_key_ignore.rb +43 -0
  96. data/test/support/shared_examples/on_duplicate_key_update.rb +378 -0
  97. data/test/support/shared_examples/recursive_import.rb +225 -0
  98. data/test/support/sqlite3/import_examples.rb +231 -0
  99. data/test/synchronize_test.rb +10 -2
  100. data/test/test_helper.rb +36 -8
  101. data/test/travis/database.yml +26 -17
  102. data/test/value_sets_bytes_parser_test.rb +25 -17
  103. data/test/value_sets_records_parser_test.rb +6 -6
  104. metadata +86 -42
  105. data/benchmarks/boot.rb +0 -18
  106. data/benchmarks/schema/mysql_schema.rb +0 -16
  107. data/gemfiles/3.1.gemfile +0 -4
  108. data/lib/activerecord-import/active_record/adapters/em_mysql2_adapter.rb +0 -8
  109. data/lib/activerecord-import/active_record/adapters/mysql_adapter.rb +0 -6
  110. data/lib/activerecord-import/em_mysql2.rb +0 -7
  111. data/lib/activerecord-import/mysql.rb +0 -7
  112. data/test/adapters/em_mysql2.rb +0 -1
  113. data/test/adapters/mysql.rb +0 -1
  114. data/test/adapters/mysqlspatial.rb +0 -1
  115. data/test/mysql/import_test.rb +0 -6
  116. data/test/mysqlspatial/import_test.rb +0 -6
  117. data/test/schema/mysql_schema.rb +0 -18
  118. data/test/travis/build.sh +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: eb77d17b829e2ac21c8816b01c3d365b4f9ddc6e
4
- data.tar.gz: 301500da2b010aaac8473af8c5436124c59c0ca0
2
+ SHA256:
3
+ metadata.gz: b32b91e70dc3ec25461a37092b774709300798912b930aeb9e7ae57dba41230d
4
+ data.tar.gz: 5b64d6bc14cae05785300a72cd830e552cd5b21d0dbb304e4e527f69de9865c5
5
5
  SHA512:
6
- metadata.gz: 242c10dbb23c6236cd2e2f10328a6c63e567c3fa55bb899c05771b37c7bc3507632495779deffdf52dcd8798c7785398be1493330d32f69953a20d3e0a1348be
7
- data.tar.gz: 1c8eccfa18fef779eb2c6c86cde365cd6254efc453b09734e19ceafe62d93af445de0042e0ef6d840f7c7e9e5546f93432ff2a3fe9bde3f4a97d6319031be2f5
6
+ metadata.gz: 04a16537b5cd4ef535e7ed1c49397b1313d2717f5b60ed43cdee42f220d3a0094d0b4cce6241470c892a184b09d74b28ece67d28506508964f962c9282aa763c
7
+ data.tar.gz: d84f9ffea3a04a2ca3b2bb3dfc05307a90876d5c7e9f8e155605dbc7a6bbcec8cd3cfefc7aac82a7e14de0ae5334cdeba3ac6467c00206ccd15e016aebe8854e
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 ADDED
@@ -0,0 +1,49 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Lint/EndAlignment:
4
+ AlignWith: variable
5
+
6
+ Metrics/AbcSize:
7
+ Enabled: false
8
+
9
+ Metrics/ClassLength:
10
+ Enabled: false
11
+
12
+ Metrics/CyclomaticComplexity:
13
+ Enabled: false
14
+
15
+ Metrics/LineLength:
16
+ Enabled: false
17
+
18
+ Metrics/MethodLength:
19
+ Enabled: false
20
+
21
+ Metrics/ModuleLength:
22
+ Enabled: false
23
+
24
+ Metrics/PerceivedComplexity:
25
+ Enabled: false
26
+
27
+ Style/AlignParameters:
28
+ EnforcedStyle: with_fixed_indentation
29
+
30
+ Style/ClassAndModuleChildren:
31
+ Enabled: false
32
+
33
+ Style/Documentation:
34
+ Enabled: false
35
+
36
+ Style/ElseAlignment:
37
+ Enabled: false
38
+
39
+ Style/SpaceInsideParens:
40
+ Enabled: false
41
+
42
+ Style/SpecialGlobalVars:
43
+ Enabled: false
44
+
45
+ Style/StringLiterals:
46
+ Enabled: false
47
+
48
+ Style/TrailingCommaInLiteral:
49
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,36 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-03-17 18:14:55 -0700 using RuboCop version 0.38.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ Lint/HandleExceptions:
11
+ Exclude:
12
+ - 'lib/activerecord-import/base.rb'
13
+ - 'test/import_test.rb'
14
+
15
+ # Offense count: 2
16
+ Lint/RescueException:
17
+ Exclude:
18
+ - 'benchmarks/lib/cli_parser.rb'
19
+ - 'test/import_test.rb'
20
+
21
+ # Offense count: 4
22
+ # Cop supports --auto-correct.
23
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
24
+ Lint/UnusedMethodArgument:
25
+ Exclude:
26
+ - 'lib/activerecord-import/adapters/postgresql_adapter.rb'
27
+ - 'lib/activerecord-import/import.rb'
28
+
29
+ # Offense count: 2
30
+ # Cop supports --auto-correct.
31
+ # Configuration parameters: Keywords.
32
+ # Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
33
+ Style/CommentAnnotation:
34
+ Exclude:
35
+ - 'benchmarks/lib/cli_parser.rb'
36
+ - 'lib/activerecord-import/import.rb'
data/.travis.yml CHANGED
@@ -1,20 +1,76 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.0.0
4
+ - 2.5.8
5
5
 
6
- gemfile:
7
- - Gemfile
6
+ env:
7
+ global:
8
+ # https://github.com/discourse/discourse/blob/master/.travis.yml
9
+ - RUBY_GC_MALLOC_LIMIT=50000000
10
+ matrix:
11
+ - AR_VERSION=5.1
12
+ - AR_VERSION=5.2
13
+ - AR_VERSION=6.0
14
+ - AR_VERSION=6.1
8
15
 
9
- bundler_args: -j2
16
+ matrix:
17
+ include:
18
+ - rvm: 2.3.8
19
+ env: AR_VERSION=3.2
20
+ - rvm: 2.3.8
21
+ env: AR_VERSION=4.0
22
+ - rvm: 2.3.8
23
+ env: AR_VERSION=4.1
24
+ - rvm: 2.3.8
25
+ env: AR_VERSION=4.2
26
+ - rvm: 2.3.8
27
+ env: AR_VERSION=5.0
28
+
29
+ fast_finish: true
30
+
31
+ addons:
32
+ postgresql: "10"
33
+ apt:
34
+ sources:
35
+ - travis-ci/sqlite3
36
+ - mysql-5.7-trusty
37
+ packages:
38
+ - sqlite3
39
+ - mysql-server
40
+ - mysql-client
41
+ - postgresql-10-postgis-2.4
42
+
43
+ before_install:
44
+ - sudo apt-get update
45
+ - gem update --system
46
+ - sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
47
+ - sudo mysql_upgrade
48
+ - sudo service mysql restart
10
49
 
11
50
  before_script:
12
51
  - mysql -e 'create database activerecord_import_test;'
13
52
  - psql -c 'create database activerecord_import_test;' -U postgres
14
- - psql -U postgres -c "create extension postgis"
53
+ - psql activerecord_import_test -c 'create extension if not exists hstore;' -U postgres
54
+ - psql -c 'create extension if not exists postgis;' -U postgres
55
+ - psql -c 'create extension if not exists "uuid-ossp";' -U postgres
15
56
  - cp test/travis/database.yml test/database.yml
16
- # https://github.com/discourse/discourse/blob/master/.travis.yml
17
- - export RUBY_GC_MALLOC_LIMIT=50000000
18
57
 
19
58
  script:
20
- - test/travis/build.sh
59
+ - bundle exec rake test:mysql2
60
+ - bundle exec rake test:mysql2_makara
61
+ - bundle exec rake test:mysql2spatial
62
+ - bundle exec rake test:postgis
63
+ - bundle exec rake test:postgresql
64
+ - bundle exec rake test:postgresql_makara
65
+ - bundle exec rake test:seamless_database_pool
66
+ - bundle exec rake test:spatialite
67
+ - bundle exec rake test:sqlite3
68
+ - bundle exec rubocop
69
+
70
+ dist: xenial
71
+
72
+ services:
73
+ - mysql
74
+ - postgresql
75
+
76
+ sudo: required
data/CHANGELOG.md ADDED
@@ -0,0 +1,475 @@
1
+ ## Changes in 1.0.8
2
+
3
+ ### Fixes
4
+
5
+ * Use correct method for clearing query cache. Thanks to @EtienneDepaulis via \##719.
6
+
7
+ ## Changes in 1.0.7
8
+
9
+ * Use @@max_allowed_packet session variable instead of querying SHOW VARIABLES. Thanks to @diclophis via \#706.
10
+ * 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.
11
+
12
+ ### Fixes
13
+
14
+ * Prevent mass-assignment errors in Rails strict mode. Thanks to @diclophis via \##709.
15
+
16
+ ## Changes in 1.0.6
17
+
18
+ ### Fixes
19
+
20
+ * Handle after_initialize callbacks. Thanks to @AhMohsen46 via \#691 and
21
+ \#692.
22
+ * Fix regression introduced in 1.0.4. Explicity allow adapters to
23
+ support on duplicate key update. Thanks to @dsobiera, @jkowens via \#696.
24
+
25
+ ## Changes in 1.0.5
26
+
27
+ ### Fixes
28
+
29
+ * Allow serialized attributes to be returned from import. Thanks to @timanovsky, @jkowens via \#660.
30
+ * Return ActiveRecord::Connection from
31
+ ActiveREcord::Base#establish_connection. Thanks to @reverentF via
32
+ \#663.
33
+ * Support PostgreSQL array. Thanks to @ujihisa via \#669.
34
+ * Skip loading association ids when column changed. Thanks to @Aristat
35
+ via \#673.
36
+
37
+ ## Changes in 1.0.4
38
+
39
+ ### Fixes
40
+
41
+ * Use prepend pattern for ActiveRecord::Base#establish_connection patching. Thanks to @dombesz via \#648.
42
+ * Fix NoMethodError when using PostgreSQL ENUM types. Thanks to @sebcoetzee via \#651.
43
+ * Fix issue updating optimistic lock in Postgres. Thanks to @timanovsky
44
+ via \#656.
45
+
46
+ ## Changes in 1.0.3
47
+
48
+ ### New Features
49
+
50
+ * Add support for ActiveRecord 6.1.0.alpha. Thanks to @imtayadeway via
51
+ \#642.
52
+
53
+ ### Fixes
54
+
55
+ * Return an empty array for results instead of nil when importing empty
56
+ array. Thanks to @gyfis via \#636.
57
+
58
+ ## Changes in 1.0.2
59
+
60
+ ### New Features
61
+
62
+ * Add support for CockroachDB adapter. Thanks to @willie via \#605.
63
+ * Add support for ActiveRecord 6.0.0.rc1. Thanks to @madeindjs, @bill-filler,
64
+ @jkowens via \#619, \#623.
65
+
66
+ ### Fixes
67
+
68
+ * Fixes NoMethodError when attempting to use nil logger. Thanks to @MattMecel,
69
+ @khiav22357.
70
+ * Fix issue validating STI models. Thanks to @thejbsmith, @jkowens via
71
+ \#626.
72
+
73
+ ## Changes in 1.0.1
74
+
75
+ ### Fixes
76
+
77
+ * Raise an error with a helpful message if array of values exceeds the number of
78
+ columns for a table. Thanks to @golddranks via \#589.
79
+ * Properly check if model responds to import before creating alias.
80
+ Thanks to @jcw- via \#591.
81
+ * No longer pass :returning option to child associations on recursive
82
+ import. Thanks to @dmitriy-kiriyenko via \#595.
83
+ * Fix import issue for models with Postgresql json/jsonb fields. Thanks
84
+ to @stokarenko via \#594.
85
+ * Fix issue importing models with timestamps that contain timezone
86
+ information. Thaks to @dekaikiwi, @jkowens via \#598.
87
+ * Ignore :no_returning when using :recursive option. Thanks to @dgollahon, @jkowens
88
+ via \#599.
89
+
90
+ ## Changes in 1.0.0
91
+
92
+ ### New Features
93
+
94
+ * Move ActiveRecord::Dirty changes to previous_changes after import.
95
+ Thanks to @stokarenko via \#584.
96
+
97
+ ### Breaking Changes
98
+
99
+ * Previously :on_duplicate_key_update was enabled by default for MySQL.
100
+ The update timestamp columns (updated_at, updated_on) would be updated
101
+ on duplicate key. This was behavior is inconsistent with the other database
102
+ adapters and could also be considered surprising. Going forward it must
103
+ be explicitly enabled. See \#548.
104
+
105
+ ## Changes in 0.28.2
106
+
107
+ ### Fixes
108
+
109
+ * Fix issue where validations where not working in certain scenarios.
110
+ Thanks to @CASIXx1 via \#579.
111
+
112
+ ## Changes in 0.28.1
113
+
114
+ ### Fixes
115
+
116
+ * Fix issue where ActiveRecord presence validations were being mutated.
117
+ Limited custom presence validation to bulk imports.
118
+
119
+ ## Changes in 0.28.0
120
+
121
+ ### New Features
122
+
123
+ * Allow updated timestamps to be manually set.Thanks to @Rob117, @jkowens via \#570.
124
+
125
+ ### Fixes
126
+
127
+ * Fix validating presence of belongs_to associations. Existence
128
+ of the parent record is not validated, but the foreign key field
129
+ cannot be empty. Thanks to @Rob117, @jkowens via \#575.
130
+
131
+ ## Changes in 0.27.0
132
+
133
+ ### New Features
134
+
135
+ * Add "secret" option validate_uniqueness to enable uniqueness
136
+ validators when validating import. This is not a recommended
137
+ approach (See #228), but is being added back in for projects
138
+ that depended on this feature. Thanks to @jkowens via \#554.
139
+
140
+ ## Changes in 0.26.0
141
+
142
+ ### New Features
143
+
144
+ * Add on_duplicate_key_update for SQLite. Thanks to @jkowens via \#542.
145
+ * Add option to update all fields on_duplicate_key_update. Thanks to @aimerald, @jkowens via \#543.
146
+
147
+ ### Fixes
148
+
149
+ * Handle deeply frozen options hashes. Thanks to @jturkel via \#546.
150
+ * Switch from FactoryGirl to FactoryBot. Thanks to @koic via \#547.
151
+ * Allow import to work with ProxySQL. Thanks to @GregFarrell via \#550.
152
+
153
+ ## Changes in 0.25.0
154
+
155
+ ### New Features
156
+
157
+ * Add support for makara_postgis adapter. Thanks to @chadwilken via \#527.
158
+ * Skip validating presence of belongs_to associations. Thanks to @Sohair63, @naiyt, @jkowens via \#528.
159
+
160
+ ### Fixes
161
+
162
+ * Add missing require for ActiveSupport.on_load. Thanks to @onk via \#529.
163
+ * Support setting attribute values in before_validation callbacks.
164
+ Thanks to @SirRawlins, @jkowens via \#531.
165
+ * Ignore virtual columns. Thanks to @dbourguignon, @jkowens via \#530.
166
+
167
+ ## Changes in 0.24.0
168
+
169
+ ### Fixes
170
+
171
+ * Use the association primary key when importing. Thanks to @dpogue via \#512.
172
+ * Allow association ids to be updated. Thanks to @Aristat via \#515.
173
+
174
+ ## Changes in 0.23.0
175
+
176
+ ### New Features
177
+
178
+ * Rename `import` method to `bulk_import` and alias to `import`. Thanks
179
+ to @itay-grudev, @jkowens via \#498.
180
+ * Increment lock_version on duplicate key update. Thanks to @aimerald
181
+ via \#500.
182
+
183
+ ### Fixes
184
+
185
+ * Fix import_without_validations_or_callbacks exception if array is empty.
186
+ Thanks to @doloopwhile via \#508.
187
+
188
+ ## Changes in 0.22.0
189
+
190
+ ### New Features
191
+
192
+ * Add support for importing hashes thru a has many association. Thanks
193
+ to @jkowens via \#483.
194
+
195
+ ### Fixes
196
+
197
+ * Fix validation logic for recursive import. For those on Rails 5.0 and 5.1,
198
+ this change requires models with polymorphic associations to specify the `inverse_of`
199
+ argument (See issue #495). Thanks to @eric-simonton-sama, @jkowens via
200
+ \#489.
201
+
202
+ ## Changes in 0.21.0
203
+
204
+ ### New Features
205
+
206
+ * Allow SQL subqueries (objects that respond to .to_sql) to be passed as values. Thanks
207
+ to @jalada, @jkowens via \#471
208
+ * Raise an ArgumentError when importing an array of hashes if any of the
209
+ hash objects have different keys. Thanks to @mbell697 via \#465.
210
+
211
+ ### Fixes
212
+
213
+ * Fix issue loading incorrect foreign key value when syncing belongs_to
214
+ associations with custom foreign key columns. Thanks to @marcgreenstock, @jkowens via \#470.
215
+ * Fix issue importing models with polymorphic belongs_to associations.
216
+ Thanks to @zorab47, @jkowens via \#476.
217
+ * Fix issue importing STI models with ActiveRecord 4.0. Thanks to
218
+ @kazuki-st, @jkowens via \#478.
219
+
220
+ ## Changes in 0.20.2
221
+
222
+ ### Fixes
223
+
224
+ * Unscope model when synchronizing with database. Thanks to @indigoviolet via \#455.
225
+
226
+ ## Changes in 0.20.1
227
+
228
+ ### Fixes
229
+
230
+ * Prevent :on_duplicate_key_update args from being modified. Thanks to @joshuamcginnis, @jkowens via \#451.
231
+
232
+ ## Changes in 0.20.0
233
+
234
+ ### New Features
235
+
236
+ * Allow returning columns to be specified for PostgreSQL. Thanks to
237
+ @tjwp via \#433.
238
+
239
+ ### Fixes
240
+
241
+ * Fixes an issue when bypassing uniqueness validators. Thanks to @vmaxv via \#444.
242
+ * For AR < 4.2, prevent type casting for binary columns on Postgresql. Thanks to @mwalsher via \#446.
243
+ * Fix issue logging class name on import. Thanks to @sophylee, @jkowens via \#447.
244
+ * Copy belongs_to association id to foreign key column before importing. Thanks to @jkowens via \#448.
245
+ * Reset model instance on validate. Thanks to @vmaxv via \#449.
246
+
247
+ ## Changes in 0.19.1
248
+
249
+ ### Fixes
250
+
251
+ * Fix a regression where models weren't properly being marked clean. Thanks to @tjwp via \#434.
252
+ * Raise ActiveRecord::Import::ValueSetTooLargeError when a record being inserted exceeds the
253
+ `max_allowed_packet` for MySQL. Thanks to @saizai, @jkowens via \#437.
254
+ * Fix issue concatenating column names array with primary key. Thanks to @keeguon via \#440.
255
+
256
+ ## Changes in 0.19.0
257
+
258
+ ### New Features
259
+
260
+ * For PostgreSQL, add option to set WHERE condition in conflict_action. Thanks to
261
+ @Saidbek via \#423.
262
+
263
+ ### Fixes
264
+
265
+ * Fix issue importing saved records with serialized fields. Thanks to
266
+ @Andreis13, @jkowens via \#425.
267
+ * Fix issue importing records that have columns defined with default values
268
+ that are functions or expressions. Thanks to @Andreis13, @jkowens via \#428.
269
+
270
+ ## Changes in 0.18.3
271
+
272
+ ### Fixes
273
+
274
+ * Set models new_record attribute to false when importing with
275
+ :on_duplicate_key_ignore. Thanks to @nijikon, @jkowens via \#416.
276
+
277
+ ## Changes in 0.18.2
278
+
279
+ ### Fixes
280
+
281
+ * Enable custom validate callbacks when validating import. Thanks to @afn via \#410.
282
+ * Prevent wrong IDs being set on models when using :on_duplicate_key_ignore.
283
+ Thanks to @afn, @jkowens via \#412.
284
+
285
+ ## Changes in 0.18.1
286
+
287
+ ### Fixes
288
+
289
+ * Fix to enable validation callbacks (before_validation,
290
+ after_validation). Thanks to @sinsoku, @jkowens via \#406.
291
+
292
+ ## Changes in 0.18.0
293
+
294
+ ### New Features
295
+
296
+ * Uniqueness validation is bypassed when validating models since
297
+ it cannot be guaranteed if there are duplicates in a batch.
298
+ Thanks to @jkowens via \#301.
299
+ * Allow for custom timestamp columns. Thanks to @mojidabckuu, @jkowens
300
+ via \#401.
301
+
302
+ ### Fixes
303
+
304
+ * Fix ActiveRecord 5 issue coercing boolean values when serializing
305
+ for the database. Thanks to @rjrobinson, @jkowens via \#403.
306
+
307
+ ## Changes in 0.17.2
308
+
309
+ ### Fixes
310
+
311
+ * Fix issue where PostgreSQL cannot recognize columns if names
312
+ include mixed case characters. Thanks to @hugobgranja via \#379.
313
+ * Fix an issue for ActiveRecord 5 where serialized fields with
314
+ default values were not being typecast. Thanks to @whistlerbrk,
315
+ @jkowens via \#386.
316
+ * Add option :force_single_insert for MySQL to make sure a single
317
+ insert is attempted instead of performing multiple inserts based
318
+ on max_allowed_packet. Thanks to @mtparet via \#387.
319
+
320
+ ## Changes in 0.17.1
321
+
322
+ ### Fixes
323
+
324
+ * Along with setting id on models for adapters that support it,
325
+ add created_at and updated_at timestamps. Thanks to @jacob-carlborg
326
+ via \#364.
327
+ * Properly set returned ids when using composite_primary_keys.
328
+ Thanks to @guigs, @jkowens via \#371.
329
+
330
+ ## Changes in 0.17.0
331
+
332
+ ### New Features
333
+
334
+ * Add support for composite_primary_keys gem. Thanks to @jkowens
335
+ via \#350.
336
+ * Add support for importing an array of hashes. Thanks to @jkowens
337
+ via \#352.
338
+ * Add JDBC SQLite3 support. Thanks to @jkowens via \#356.
339
+
340
+ ### Fixes
341
+
342
+ * Remove support for SQLite recursive imports. See \#351.
343
+ * Improve import speed for Rails 5. Thanks to @ranchodeluxe, @jkowens
344
+ via \#359.
345
+
346
+ ## Changes in 0.16.2
347
+
348
+ ### Fixes
349
+
350
+ * Fixes issue clearing query cache on wrong connection when using
351
+ multiple databases. Thanks to @KentoMoriwaki via \#337
352
+ * Raises an ArgumentError on incorrect usage of nested arrays. Thanks
353
+ to @Nitrodist via \#340
354
+ * Fixes issue that prevented uuid primary keys from being set manually.
355
+ Thanks to @Dclusin-og, @jkowens via \#342
356
+
357
+ ## Changes in 0.16.1
358
+
359
+ ### Fixes
360
+
361
+ * Fixes issue with missing error messages on failed instances when
362
+ importing using arrays of columns and values. Thanks to @Fivell via \#332
363
+ * Update so SQLite only return ids if table has a primary key field via \#333
364
+
365
+
366
+ ## Changes in 0.16.0
367
+
368
+ ### New Features
369
+
370
+ * Add partial index upsert support for PostgreSQL. Thanks to @luislew via \#305
371
+ * Add UUID primary key support for PostgreSQL. Thanks to @jkowens via
372
+ \#312
373
+ * Add store accessor support for JSON, JSON, and HSTORE data types.
374
+ Thanks to @jkowens via \#322
375
+ * Log warning if database does not support :on_duplicate_key_update.
376
+ Thanks to @jkowens via \#324
377
+ * Add option :on_duplicate_key_ignore for MySQL and SQLite. Thanks to
378
+ @jkowens via \#326
379
+
380
+ ### Fixes
381
+
382
+ * Fixes issue with recursive import using same primary key for all models.
383
+ Thanks to @chopraanmol1 via \#309
384
+ * Fixes issue importing from STI subclass with polymorphic associations.
385
+ Thanks to @JNajera via \#314
386
+ * 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
387
+
388
+
389
+ ## Changes in 0.15.0
390
+
391
+ ### New Features
392
+
393
+ * 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
394
+ * Support for Rails 5.0 final release for all except the JDBC driver which is not yet updated to support Rails 5.0
395
+
396
+ ### Fixes
397
+
398
+ * 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
399
+
400
+ ### Misc
401
+
402
+ * `raise_error` is used to raise errors for ActiveRecord 5.0. Thanks to @couragecourag via \#294 `raise_record_invalid` has been
403
+
404
+
405
+ ## Changes in 0.14.1
406
+
407
+ ### Fixes
408
+
409
+ * JRuby/JDBCDriver with PostgreSQL will no longer raise a JDBCDriver error when using the :no_returning boolean option. Thanks to @jkowens via \#287
410
+
411
+ ## Changes in 0.14.0
412
+
413
+ ### New Features
414
+
415
+ * Support for ActiveRecord 3.1 has been dropped. Thanks to @sferik via \#254
416
+ * SQLite3 has learned the :recursive option. Thanks to @jkowens via \#281
417
+ * :on_duplicate_key_ignore will be ignored when imports are being done with :recursive. Thanks to @jkowens via \#268
418
+ * :activerecord-import learned how to tell PostgreSQL to return no data back from the import via the :no_returning boolean option. Thanks to @makaroni4 via \#276
419
+
420
+ ### Fixes
421
+
422
+ * Polymorphic associations will not import the :type column. Thanks to @seanlinsley via \#282 and \#283
423
+ * ~2X speed increase for importing models with validations. Thanks to @jkowens via \#266
424
+
425
+ ### Misc
426
+
427
+ * Benchmark HTML report has been fixed. Thanks to @jkowens via \#264
428
+ * seamless_database_pool has been updated to work with AR 5.0. Thanks to @jkowens via \#280
429
+ * Code cleanup, removal of redundant condition checks. Thanks to @pavlik4k via \#273
430
+ * Code cleanup, removal of deprecated `alias_method_chain`. Thanks to @codeodor via \#271
431
+
432
+
433
+ ## Changes in 0.13.0
434
+
435
+ ### New Features
436
+
437
+ * Addition of :batch_size option to control the number of rows to insert per INSERT statement. The default is the total number of records being inserted so there is a single INSERT statement. Thanks to @jkowens via \#245
438
+
439
+ * Addition `import!` which will raise an exception if a validation occurs. It will fail fast. Thanks to @jkowens via \#246
440
+
441
+ ### Fixes
442
+
443
+ * Fixing issue with recursive import when utilizing the `:on_duplicate_key_update` option. The `on_duplicate_key_update` only applies to parent models at this time. Thanks to @yuri-karpovich for reporting and @jkowens for fixing via \#249
444
+
445
+ ### Misc
446
+
447
+ * Refactoring of fetching and assigning attributes. Thanks to @jkownes via \#259
448
+ * Lots of code cleanup and addition of Rubocop linter. Thanks to @sferik via \#256 and \#250
449
+ * Resolving errors with the test suite when running against ActiveRecord 4.0 and 4.1. Thanks to @jkowens via \#262
450
+ * Cleaning up the TravisCI settings and packages. Thanks to @sferik via \#258 and \#251
451
+
452
+ ## Changes in 0.12.0
453
+
454
+ ### New Features
455
+
456
+ * PostgreSQL UPSERT support has been added. Thanks @jkowens via \#218
457
+
458
+ ### Fixes
459
+
460
+ * has_one and has_many associations will now be recursively imported regardless of :autosave being set. Thanks @sferik, @jkowens via \#243, \#234
461
+ * Fixing an issue with enum column support for Rails > 4.1. Thanks @aquajach via \#235
462
+
463
+ ### Removals
464
+
465
+ * Support for em-synchrony has been removed since it appears the project has been abandoned. Thanks @sferik, @zdennis via \#239
466
+ * Support for the mysql gem/adapter has been removed since it has officially been abandoned. Use the mysql2 gem/adapter instead. Thanks @sferik, @zdennis via \#239
467
+
468
+ ### Misc
469
+
470
+ * Cleaned up TravisCI output and removing deprecation warnings. Thanks @jkowens, @zdennis \#242
471
+
472
+
473
+ ## Changes before 0.12.0
474
+
475
+ > Never look back. What's gone is now history. But in the process make memory of events to help you understand what will help you to make your dream a true story. Mistakes of the past are lessons, success of the past is inspiration. – Dr. Anil Kr Sinha