composite_primary_keys 14.0.8 → 14.0.9

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
  SHA256:
3
- metadata.gz: 717baef11c50b8c166a79ddb4c024c5c9bb1665062381125a338ad11f1d87fc0
4
- data.tar.gz: dfb9f5b2cba6bb0f95a2f27126eba9b08a24eb3189ca7abcdfed98e30464e39d
3
+ metadata.gz: d4675084d63630478cb5ad93843fe68c06e1820cc228fd8a1f95338851b901bd
4
+ data.tar.gz: ed8a13dcf2aee66e3fcf20f89e14049660eb7ee00341f9967a95cfd23dbbd259
5
5
  SHA512:
6
- metadata.gz: 4561141fc8ecbd420dbeb2e0e0c8b28c77cd8f2156e0bcf073776b17dd9cb3c9b5703ae159791c151973668aa6cfd46547501201a818a78ffcb553abf498a58f
7
- data.tar.gz: c9bec41adfcd267e6b728831b7668b0634a69edaf5a84785a0ec2c1d77f1892b09c7e5044416aac66cdc9039a46e09cc1e855e28c70e182fbc2bf287cf71623c
6
+ metadata.gz: 18089b861f3fd8bf7d6adf998c92235f34e3e786aa7de12590988f68580a63eb0551e338b59cc491e6d322a429e143f67245bebc85137d11f5bc087faa5abbfe
7
+ data.tar.gz: 5bb22276acefd46ed09e078bb999df86d7e1885304b855c7e6493733d13f859cd9a31b58177c971825d874b57fb5388d33dc6d3f715d58aa344b1f3f8e415f67
data/History.rdoc CHANGED
@@ -1,3 +1,6 @@
1
+ == 14.0.9 (2023-12-03)
2
+ * Fix Error for Array-Based Composite Keys in nested_attribute (T.S.)
3
+
1
4
  == 14.0.8 (2023-11-24)
2
5
  * Support polymorphic_name (Vladimir Kochnev)
3
6
  * Fix HasOneThrough association (kyori19)
@@ -61,12 +61,12 @@ module ActiveRecord
61
61
  unless reject_new_record?(association_name, attributes)
62
62
  association.reader.build(attributes.except(*UNASSIGNABLE_KEYS))
63
63
  end
64
- elsif existing_record = existing_records.detect { |record| record.id.to_s == attributes["id"].to_s }
64
+ elsif existing_record = cpk_detect_record(attributes['id'], existing_records)
65
65
  unless call_reject_if(association_name, attributes)
66
66
  # Make sure we are operating on the actual object which is in the association's
67
67
  # proxy_target array (either by finding it, or adding it if not found)
68
68
  # Take into account that the proxy_target may have changed due to callbacks
69
- target_record = association.target.detect { |record| record.id.to_s == attributes["id"].to_s }
69
+ target_record = cpk_detect_record(attributes['id'], association.target)
70
70
  if target_record
71
71
  existing_record = target_record
72
72
  else
@@ -2,7 +2,7 @@ module CompositePrimaryKeys
2
2
  module VERSION
3
3
  MAJOR = 14
4
4
  MINOR = 0
5
- TINY = 8
5
+ TINY = 9
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
8
  end
@@ -64,4 +64,27 @@ class TestNestedAttributes < ActiveSupport::TestCase
64
64
  assert_equal(reference_code.code_label, 'XX')
65
65
  assert_equal(reference_code.abbreviation, 'Xx')
66
66
  end
67
+
68
+ def test_nested_atttribute_update_4
69
+ code_id = 1003
70
+
71
+ reference_type = reference_types(:name_prefix)
72
+ reference_type.update :reference_codes_attributes => [{
73
+ :reference_code => code_id,
74
+ :code_label => 'XX',
75
+ :abbreviation => 'Xx'
76
+ }]
77
+ assert_not_nil ReferenceCode.find_by_reference_code(code_id)
78
+ reference_code = ReferenceCode.find_by_reference_code(code_id)
79
+ # directly pass :id as a array
80
+ reference_type.update :reference_codes_attributes => [{
81
+ :id => [reference_type.reference_type_id, code_id],
82
+ :code_label => 'AAA',
83
+ :abbreviation => 'Aaa'
84
+ }]
85
+
86
+ reference_code = ReferenceCode.find_by_reference_code(code_id)
87
+ assert_kind_of(ReferenceCode, reference_code)
88
+ assert_equal(reference_code.code_label, 'AAA')
89
+ end
67
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composite_primary_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.0.8
4
+ version: 14.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Savage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-24 00:00:00.000000000 Z
11
+ date: 2023-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord