activerecord-import 0.20.0 → 0.20.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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +6 -0
- data/lib/activerecord-import/adapters/postgresql_adapter.rb +1 -1
- data/lib/activerecord-import/import.rb +7 -2
- data/lib/activerecord-import/version.rb +1 -1
- data/test/support/postgresql/import_examples.rb +7 -0
- data/test/support/shared_examples/on_duplicate_key_update.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7e1b67259d7a4d62e746876dfd781042aadba1
|
4
|
+
data.tar.gz: 3eedcc2001fae319e4867e292843a23c2bec1223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28a9b68a29cb302d421051b406989211926e7b65c6e9edba0a016787a33c23d8e8e3ba76b21946eeb7241014c17786e95213a6e65a9d72589c4c12e8cbf41864
|
7
|
+
data.tar.gz: aa61794f8678bb6ef3ebfc5d75728029f13ac1b87147cb1156bc414deaa8788c2fd08ed88d0ecd71963c4ee42a58d1d140ca80b7783d376238877435560a8a03
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -177,7 +177,7 @@ module ActiveRecord::Import::PostgreSQLAdapter
|
|
177
177
|
if constraint_name.present?
|
178
178
|
"ON CONSTRAINT #{constraint_name} "
|
179
179
|
elsif conflict_target.present?
|
180
|
-
'(' << Array( conflict_target ).reject( &:
|
180
|
+
'(' << Array( conflict_target ).reject( &:blank? ).join( ', ' ) << ') '.tap do |sql|
|
181
181
|
sql << "WHERE #{index_predicate} " if index_predicate
|
182
182
|
end
|
183
183
|
end
|
@@ -415,8 +415,13 @@ class ActiveRecord::Base
|
|
415
415
|
options[:primary_key] = primary_key
|
416
416
|
|
417
417
|
# Don't modify incoming arguments
|
418
|
-
|
419
|
-
|
418
|
+
on_duplicate_key_update = options[:on_duplicate_key_update]
|
419
|
+
if on_duplicate_key_update && on_duplicate_key_update.duplicable?
|
420
|
+
options[:on_duplicate_key_update] = if on_duplicate_key_update.is_a?(Hash)
|
421
|
+
on_duplicate_key_update.each { |k, v| on_duplicate_key_update[k] = v.dup if v.duplicable? }
|
422
|
+
else
|
423
|
+
on_duplicate_key_update.dup
|
424
|
+
end
|
420
425
|
end
|
421
426
|
|
422
427
|
is_validating = options[:validate]
|
@@ -309,6 +309,13 @@ def should_support_postgresql_upsert_functionality
|
|
309
309
|
@topic = Topic.find 99
|
310
310
|
end
|
311
311
|
|
312
|
+
it "should not modify the passed in :on_duplicate_key_update columns array" do
|
313
|
+
assert_nothing_raised do
|
314
|
+
columns = %w(title author_name).freeze
|
315
|
+
Topic.import columns, [%w(foo, bar)], on_duplicate_key_update: { columns: columns }
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
312
319
|
context "using string hash map" do
|
313
320
|
let(:update_columns) { { "title" => "title", "author_email_address" => "author_email_address", "parent_id" => "parent_id" } }
|
314
321
|
should_support_on_duplicate_key_update
|
@@ -7,7 +7,7 @@ def should_support_basic_on_duplicate_key_update
|
|
7
7
|
|
8
8
|
context "with :on_duplicate_key_update" do
|
9
9
|
describe "argument safety" do
|
10
|
-
it "should not modify the passed in :on_duplicate_key_update
|
10
|
+
it "should not modify the passed in :on_duplicate_key_update array" do
|
11
11
|
assert_nothing_raised do
|
12
12
|
columns = %w(title author_name).freeze
|
13
13
|
Topic.import columns, [%w(foo, bar)], on_duplicate_key_update: columns
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|