activerecord-import 0.19.0 → 0.28.2

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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +22 -12
  3. data/CHANGELOG.md +151 -0
  4. data/Gemfile +13 -10
  5. data/README.markdown +548 -5
  6. data/Rakefile +2 -1
  7. data/benchmarks/lib/cli_parser.rb +2 -1
  8. data/gemfiles/5.1.gemfile +1 -0
  9. data/gemfiles/5.2.gemfile +2 -0
  10. data/lib/activerecord-import/adapters/abstract_adapter.rb +2 -2
  11. data/lib/activerecord-import/adapters/mysql_adapter.rb +15 -6
  12. data/lib/activerecord-import/adapters/postgresql_adapter.rb +59 -15
  13. data/lib/activerecord-import/adapters/sqlite3_adapter.rb +126 -3
  14. data/lib/activerecord-import/base.rb +4 -6
  15. data/lib/activerecord-import/import.rb +381 -126
  16. data/lib/activerecord-import/synchronize.rb +1 -1
  17. data/lib/activerecord-import/value_sets_parser.rb +14 -0
  18. data/lib/activerecord-import/version.rb +1 -1
  19. data/lib/activerecord-import.rb +2 -15
  20. data/test/adapters/makara_postgis.rb +1 -0
  21. data/test/import_test.rb +148 -14
  22. data/test/makara_postgis/import_test.rb +8 -0
  23. data/test/models/account.rb +3 -0
  24. data/test/models/bike_maker.rb +7 -0
  25. data/test/models/topic.rb +10 -0
  26. data/test/models/user.rb +3 -0
  27. data/test/models/user_token.rb +4 -0
  28. data/test/schema/generic_schema.rb +20 -0
  29. data/test/schema/mysql2_schema.rb +19 -0
  30. data/test/schema/postgresql_schema.rb +1 -0
  31. data/test/schema/sqlite3_schema.rb +13 -0
  32. data/test/support/factories.rb +9 -8
  33. data/test/support/generate.rb +6 -6
  34. data/test/support/mysql/import_examples.rb +14 -2
  35. data/test/support/postgresql/import_examples.rb +136 -0
  36. data/test/support/shared_examples/on_duplicate_key_update.rb +252 -1
  37. data/test/support/shared_examples/recursive_import.rb +41 -11
  38. data/test/support/sqlite3/import_examples.rb +187 -10
  39. data/test/synchronize_test.rb +8 -0
  40. data/test/test_helper.rb +9 -1
  41. data/test/value_sets_bytes_parser_test.rb +13 -2
  42. metadata +19 -4
  43. data/test/schema/mysql_schema.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a15b84eab5c3e37adc77106a0c55a8cb030d6d3
4
- data.tar.gz: b2cab0765b2dcb2465dd6178a767836da1b61d65
3
+ metadata.gz: 39f2e5b83b07075c09bba10e3c9a53953b484641
4
+ data.tar.gz: 28869f9586c6200e932a34dadbed9f4790ee820d
5
5
  SHA512:
6
- metadata.gz: c70a9f7ea0ac30697a9342d3243b459a38fc78048ee7287b4172da5353939fd4fbb73567a9ab7c79b7b0ef9e3a367b8ea9c0e6ec78c89050db36964735fc4782
7
- data.tar.gz: 1193d03b7d5ddb8cab84110a2d34c57df9a5c6fca2d38c9967d64dd0e9573d7b3c85a88c3448b3f5a6270a6ddafc459083e5fecd2d50a26a79d7c7c50184ce3a
6
+ metadata.gz: dad31c1f3f11c1b6ba63cf2c5e65d71713603cb7604cac06e35d2786f34394e88a2ad69bc76fcaf14d7cd90e84fa277e84427425aa27cd0bcb65c61024990e1a
7
+ data.tar.gz: e842906754fd995d1be896e7929213919426ccf9c107f06c996c0216b9331c3232ff85ceb622c9de4678de6ff639e22ee783c5482bb9fbdb8c5740df46d55304
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.3.3
4
+ - 2.3.7
5
5
 
6
6
  env:
7
7
  global:
@@ -14,13 +14,12 @@ env:
14
14
  - AR_VERSION=4.2
15
15
  - AR_VERSION=5.0
16
16
  - AR_VERSION=5.1
17
+ - AR_VERSION=5.2
17
18
 
18
19
  matrix:
19
20
  include:
20
- - rvm: jruby-9.1.7.0
21
+ - rvm: jruby-9.1.14.0
21
22
  env: AR_VERSION=4.2
22
- before_install:
23
- - gem update --system
24
23
 
25
24
  script:
26
25
  - bundle exec rake test:jdbcsqlite3
@@ -29,23 +28,32 @@ matrix:
29
28
 
30
29
  fast_finish: true
31
30
 
32
- before_script:
33
- - mysql -e 'create database activerecord_import_test;'
34
- - psql -c 'create database activerecord_import_test;' -U postgres
35
- - psql activerecord_import_test -c 'create extension if not exists hstore;' -U postgres
36
- - psql -c 'create extension if not exists postgis;' -U postgres
37
- - psql -c 'create extension if not exists "uuid-ossp";' -U postgres
38
- - cp test/travis/database.yml test/database.yml
39
-
40
31
  addons:
41
32
  postgresql: "9.5"
42
33
  apt:
43
34
  sources:
44
35
  - travis-ci/sqlite3
36
+ - mysql-5.7-trusty
45
37
  packages:
46
38
  - sqlite3
39
+ - mysql-server
40
+ - mysql-client
47
41
  - postgresql-9.5-postgis-2.3
48
42
 
43
+ before_install:
44
+ - gem update --system
45
+ - sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
46
+ - sudo mysql_upgrade
47
+ - sudo service mysql restart
48
+
49
+ before_script:
50
+ - mysql -e 'create database activerecord_import_test;'
51
+ - psql -c 'create database activerecord_import_test;' -U postgres
52
+ - psql activerecord_import_test -c 'create extension if not exists hstore;' -U postgres
53
+ - psql -c 'create extension if not exists postgis;' -U postgres
54
+ - psql -c 'create extension if not exists "uuid-ossp";' -U postgres
55
+ - cp test/travis/database.yml test/database.yml
56
+
49
57
  script:
50
58
  - bundle exec rake test:mysql2
51
59
  - bundle exec rake test:mysql2_makara
@@ -59,3 +67,5 @@ script:
59
67
  - bundle exec rubocop
60
68
 
61
69
  dist: trusty
70
+
71
+ sudo: required
data/CHANGELOG.md CHANGED
@@ -1,3 +1,154 @@
1
+ ## Changes in 0.28.2
2
+
3
+ ### Fixes
4
+
5
+ * Fix issue where validations where not working in certain scenarios.
6
+ Thanks to @CASIXx1 via \#579.
7
+
8
+ ## Changes in 0.28.1
9
+
10
+ ### Fixes
11
+
12
+ * Fix issue where ActiveRecord presence validations were being mutated.
13
+ Limited custom presence validation to bulk imports.
14
+
15
+ ## Changes in 0.28.0
16
+
17
+ ### New Features
18
+
19
+ * Allow updated timestamps to be manually set.Thanks to @Rob117, @jkowens via \#570.
20
+
21
+ ### Fixes
22
+
23
+ * Fix validating presence of belongs_to associations. Existence
24
+ of the parent record is not validated, but the foreign key field
25
+ cannot be empty. Thanks to @Rob117, @jkowens via \#575.
26
+
27
+ ## Changes in 0.27.0
28
+
29
+ ### New Features
30
+
31
+ * Add "secret" option validate_uniqueness to enable uniqueness
32
+ validators when validating import. This is not a recommended
33
+ approach (See #228), but is being added back in for projects
34
+ that depended on this feature. Thanks to @jkowens via \#554.
35
+
36
+ ## Changes in 0.26.0
37
+
38
+ ### New Features
39
+
40
+ * Add on_duplicate_key_update for SQLite. Thanks to @jkowens via \#542.
41
+ * Add option to update all fields on_duplicate_key_update. Thanks to @aimerald, @jkowens via \#543.
42
+
43
+ ### Fixes
44
+
45
+ * Handle deeply frozen options hashes. Thanks to @jturkel via \#546.
46
+ * Switch from FactoryGirl to FactoryBot. Thanks to @koic via \#547.
47
+ * Allow import to work with ProxySQL. Thanks to @GregFarrell via \#550.
48
+
49
+ ## Changes in 0.25.0
50
+
51
+ ### New Features
52
+
53
+ * Add support for makara_postgis adapter. Thanks to @chadwilken via \#527.
54
+ * Skip validating presence of belongs_to associations. Thanks to @Sohair63, @naiyt, @jkowens via \#528.
55
+
56
+ ### Fixes
57
+
58
+ * Add missing require for ActiveSupport.on_load. Thanks to @onk via \#529.
59
+ * Support setting attribute values in before_validation callbacks.
60
+ Thanks to @SirRawlins, @jkowens via \#531.
61
+ * Ignore virtual columns. Thanks to @dbourguignon, @jkowens via \#530.
62
+
63
+ ## Changes in 0.24.0
64
+
65
+ ### Fixes
66
+
67
+ * Use the association primary key when importing. Thanks to @dpogue via \#512.
68
+ * Allow association ids to be updated. Thanks to @Aristat via \#515.
69
+
70
+ ## Changes in 0.23.0
71
+
72
+ ### New Features
73
+
74
+ * Rename `import` method to `bulk_import` and alias to `import`. Thanks
75
+ to @itay-grudev, @jkowens via \#498.
76
+ * Increment lock_version on duplicate key update. Thanks to @aimerald
77
+ via \#500.
78
+
79
+ ### Fixes
80
+
81
+ * Fix import_without_validations_or_callbacks exception if array is empty.
82
+ Thanks to @doloopwhile via \#508.
83
+
84
+ ## Changes in 0.22.0
85
+
86
+ ### New Features
87
+
88
+ * Add support for importing hashes thru a has many association. Thanks
89
+ to @jkowens via \#483.
90
+
91
+ ### Fixes
92
+
93
+ * Fix validation logic for recursive import. For those on Rails 5.0 and 5.1,
94
+ this change requires models with polymorphic associations to specify the `inverse_of`
95
+ argument (See issue #495). Thanks to @eric-simonton-sama, @jkowens via
96
+ \#489.
97
+
98
+ ## Changes in 0.21.0
99
+
100
+ ### New Features
101
+
102
+ * Allow SQL subqueries (objects that respond to .to_sql) to be passed as values. Thanks
103
+ to @jalada, @jkowens via \#471
104
+ * Raise an ArgumentError when importing an array of hashes if any of the
105
+ hash objects have different keys. Thanks to @mbell697 via \#465.
106
+
107
+ ### Fixes
108
+
109
+ * Fix issue loading incorrect foreign key value when syncing belongs_to
110
+ associations with custom foreign key columns. Thanks to @marcgreenstock, @jkowens via \#470.
111
+ * Fix issue importing models with polymorphic belongs_to associations.
112
+ Thanks to @zorab47, @jkowens via \#476.
113
+ * Fix issue importing STI models with ActiveRecord 4.0. Thanks to
114
+ @kazuki-st, @jkowens via \#478.
115
+
116
+ ## Changes in 0.20.2
117
+
118
+ ### Fixes
119
+
120
+ * Unscope model when synchronizing with database. Thanks to @indigoviolet via \#455.
121
+
122
+ ## Changes in 0.20.1
123
+
124
+ ### Fixes
125
+
126
+ * Prevent :on_duplicate_key_update args from being modified. Thanks to @joshuamcginnis, @jkowens via \#451.
127
+
128
+ ## Changes in 0.20.0
129
+
130
+ ### New Features
131
+
132
+ * Allow returning columns to be specified for PostgreSQL. Thanks to
133
+ @tjwp via \#433.
134
+
135
+ ### Fixes
136
+
137
+ * Fixes an issue when bypassing uniqueness validators. Thanks to @vmaxv via \#444.
138
+ * For AR < 4.2, prevent type casting for binary columns on Postgresql. Thanks to @mwalsher via \#446.
139
+ * Fix issue logging class name on import. Thanks to @sophylee, @jkowens via \#447.
140
+ * Copy belongs_to association id to foreign key column before importing. Thanks to @jkowens via \#448.
141
+ * Reset model instance on validate. Thanks to @vmaxv via \#449.
142
+
143
+ ## Changes in 0.19.1
144
+
145
+ ### Fixes
146
+
147
+ * Fix a regression where models weren't properly being marked clean. Thanks to @tjwp via \#434.
148
+ * Raise ActiveRecord::Import::ValueSetTooLargeError when a record being inserted exceeds the
149
+ `max_allowed_packet` for MySQL. Thanks to @saizai, @jkowens via \#437.
150
+ * Fix issue concatenating column names array with primary key. Thanks to @keeguon via \#440.
151
+
1
152
  ## Changes in 0.19.0
2
153
 
3
154
  ### New Features
data/Gemfile CHANGED
@@ -2,14 +2,19 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ version = ENV['AR_VERSION'].to_f
6
+
7
+ mysql2_version = '0.3.0'
8
+ mysql2_version = '0.4.0' if version >= 4.2
9
+
5
10
  group :development, :test do
6
- gem 'rubocop', '~> 0.38.0'
11
+ gem 'rubocop', '~> 0.40.0'
7
12
  gem 'rake'
8
13
  end
9
14
 
10
15
  # Database Adapters
11
16
  platforms :ruby do
12
- gem "mysql2", "~> 0.3.0"
17
+ gem "mysql2", "~> #{mysql2_version}"
13
18
  gem "pg", "~> 0.9"
14
19
  gem "sqlite3", "~> 1.3.10"
15
20
  gem "seamless_database_pool", "~> 1.0.20"
@@ -18,16 +23,16 @@ end
18
23
  platforms :jruby do
19
24
  gem "jdbc-mysql"
20
25
  gem "jdbc-postgres"
21
- gem "activerecord-jdbcsqlite3-adapter"
22
- gem "activerecord-jdbcmysql-adapter"
23
- gem "activerecord-jdbcpostgresql-adapter"
26
+ gem "activerecord-jdbcsqlite3-adapter", "~> 1.3"
27
+ gem "activerecord-jdbcmysql-adapter", "~> 1.3"
28
+ gem "activerecord-jdbcpostgresql-adapter", "~> 1.3"
24
29
  end
25
30
 
26
31
  # Support libs
27
- gem "factory_girl", "~> 4.2.0"
32
+ gem "factory_bot"
28
33
  gem "timecop"
29
34
  gem "chronic"
30
- gem "mocha"
35
+ gem "mocha", "~> 1.3.0"
31
36
 
32
37
  # Debugging
33
38
  platforms :jruby do
@@ -43,9 +48,7 @@ platforms :ruby do
43
48
  gem "rb-readline"
44
49
  end
45
50
 
46
- version = ENV['AR_VERSION'] || "4.2"
47
-
48
- if version >= "4.0"
51
+ if version >= 4.0
49
52
  gem "minitest"
50
53
  else
51
54
  gem "test-unit"