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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4613a9ba2a76e71320a6e8107b9b557f2413212
4
- data.tar.gz: 2fb7c7b7a5f801cd591e5cea93b088f0f6d52499
3
+ metadata.gz: 2d7e1b67259d7a4d62e746876dfd781042aadba1
4
+ data.tar.gz: 3eedcc2001fae319e4867e292843a23c2bec1223
5
5
  SHA512:
6
- metadata.gz: 72af6c0e217ef61e3bb87b1d078193d979f7d42e34dc5c721d5a26e72c50f1ce2b5a4a68808a2e4514b4a48135017c96cfef29e0dff4283fbc801d87b5039e18
7
- data.tar.gz: 8b22f10f28ac4e0d7f7d66c4422abb6c4d7ff616a108ad5192cd4ba257e464c15b0dcb1f802c97a4f27bce1e6b57edaa48903d9ccfe68e75cd6c89ec0fa1229e
6
+ metadata.gz: 28a9b68a29cb302d421051b406989211926e7b65c6e9edba0a016787a33c23d8e8e3ba76b21946eeb7241014c17786e95213a6e65a9d72589c4c12e8cbf41864
7
+ data.tar.gz: aa61794f8678bb6ef3ebfc5d75728029f13ac1b87147cb1156bc414deaa8788c2fd08ed88d0ecd71963c4ee42a58d1d140ca80b7783d376238877435560a8a03
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.3.3
4
+ - 2.3.5
5
5
 
6
6
  env:
7
7
  global:
@@ -17,7 +17,7 @@ env:
17
17
 
18
18
  matrix:
19
19
  include:
20
- - rvm: jruby-9.1.7.0
20
+ - rvm: jruby-9.1.9.0
21
21
  env: AR_VERSION=4.2
22
22
  before_install:
23
23
  - gem update --system
@@ -1,3 +1,9 @@
1
+ ## Changes in 0.20.1
2
+
3
+ ### Fixes
4
+
5
+ * Prevent :on_duplicate_key_update args from being modified. Thanks to @joshuamcginnis, @jkowens via \#451.
6
+
1
7
  ## Changes in 0.20.0
2
8
 
3
9
  ### New Features
@@ -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( &:empty? ).join( ', ' ) << ') '.tap do |sql|
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
- if options[:on_duplicate_key_update] && options[:on_duplicate_key_update].duplicable?
419
- options[:on_duplicate_key_update] = options[:on_duplicate_key_update].dup
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]
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Import
3
- VERSION = "0.20.0".freeze
3
+ VERSION = "0.20.1".freeze
4
4
  end
5
5
  end
@@ -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 columns array" do
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.0
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-12 00:00:00.000000000 Z
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord