composite_primary_keys 11.0.2 → 11.0.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb2211207f8a43539739b1d61b5d9f0c655e5ef3d1a0d53a7399fe550c25d36e
|
4
|
+
data.tar.gz: 512b0acad25f57c1d9796c7196827bf9a3c58be3319df5f6c0a11ea16658da09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19c175e1fc9f6ee5290573b75a1370314cfdb0598f65397ac99d616cc48d7a8a7a679ead3040f17249ff3419cbb0bb39355dc458dc4c12ce1235cf04b6dcf8be
|
7
|
+
data.tar.gz: ae880cc7d8c05910b601b9ca99a935468ec70bc6f440daf1015e1932f1544d73340f3bbacd8513a7cfe1f0f86d31df7c74b0ca2da47d31424027b58a012ce2d0
|
data/History.rdoc
CHANGED
@@ -2,16 +2,22 @@ module ActiveRecord
|
|
2
2
|
module AttributeMethods
|
3
3
|
module Read
|
4
4
|
def read_attribute(attr_name, &block)
|
5
|
+
name = if self.class.attribute_alias?(attr_name)
|
6
|
+
# CPK
|
7
|
+
# self.class.attribute_alias(attr_name).to_s
|
8
|
+
self.class.attribute_alias(attr_name)
|
9
|
+
else
|
10
|
+
# CPK
|
11
|
+
# attr_name.to_s
|
12
|
+
attr_name
|
13
|
+
end
|
14
|
+
|
15
|
+
primary_key = self.class.primary_key
|
5
16
|
# CPK
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# CPK
|
11
|
-
#name = self.class.primary_key if name == 'id'.freeze
|
12
|
-
name = self.class.primary_key if name == 'id'.freeze && !composite?
|
13
|
-
_read_attribute(name, &block)
|
14
|
-
end
|
17
|
+
# name = primary_key if name == "id".freeze && primary_key
|
18
|
+
name = primary_key if name == "id".freeze && primary_key && !composite?
|
19
|
+
sync_with_transaction_state if name == primary_key
|
20
|
+
_read_attribute(name, &block)
|
15
21
|
end
|
16
22
|
|
17
23
|
def _read_attribute(attr_name)
|
@@ -3,41 +3,35 @@ module ActiveRecord
|
|
3
3
|
module Write
|
4
4
|
def write_attribute(attr_name, value)
|
5
5
|
name = if self.class.attribute_alias?(attr_name)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
# CPK
|
7
|
+
#self.class.attribute_alias(attr_name).to_s
|
8
|
+
self.class.attribute_alias(attr_name)
|
9
|
+
else
|
10
|
+
# CPK
|
11
|
+
# attr_name.to_s
|
12
|
+
attr_name
|
13
|
+
end
|
14
14
|
|
15
|
-
|
15
|
+
primary_key = self.class.primary_key
|
16
|
+
# CPK
|
17
|
+
# name = primary_key if name == "id".freeze && primary_key
|
18
|
+
name = primary_key if name == "id".freeze && primary_key && !composite?
|
19
|
+
sync_with_transaction_state if name == primary_key
|
20
|
+
_write_attribute(name, value)
|
16
21
|
end
|
17
22
|
|
18
|
-
def
|
23
|
+
def _write_attribute(attr_name, value) # :nodoc:
|
19
24
|
# CPK
|
20
25
|
if attr_name.kind_of?(Array)
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
attr_name.each_with_index do |attr_child_name, i|
|
27
|
+
child_value = value ? value[i] : value
|
28
|
+
@attributes.write_from_user(attr_child_name.to_s, child_value)
|
24
29
|
end
|
25
|
-
[attr_name, value].transpose.map {|name,val| write_attribute(name, val)}
|
26
|
-
value
|
27
30
|
else
|
28
|
-
attr_name
|
29
|
-
# CPK
|
30
|
-
# attr_name = self.class.primary_key if attr_name == 'id' && self.class.primary_key
|
31
|
-
attr_name = self.class.primary_key if attr_name == 'id' && self.class.primary_key && !self.composite?
|
32
|
-
|
33
|
-
if should_type_cast
|
34
|
-
@attributes.write_from_user(attr_name, value)
|
35
|
-
else
|
36
|
-
@attributes.write_cast_value(attr_name, value)
|
37
|
-
end
|
38
|
-
|
39
|
-
value
|
31
|
+
@attributes.write_from_user(attr_name.to_s, value)
|
40
32
|
end
|
33
|
+
|
34
|
+
value
|
41
35
|
end
|
42
36
|
end
|
43
37
|
end
|
data/test/test_associations.rb
CHANGED
@@ -237,7 +237,7 @@ class TestAssociations < ActiveSupport::TestCase
|
|
237
237
|
assert_equal({"department_id"=>[1, 2]}, steve.changes)
|
238
238
|
end
|
239
239
|
|
240
|
-
def
|
240
|
+
def test_composite_belongs_to_setting_to_nil
|
241
241
|
room_assignment = room_assignments(:jacksons_room)
|
242
242
|
# This was raising an error before:
|
243
243
|
# NoMethodError: undefined method `length' for nil:NilClass
|
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: 11.0.
|
4
|
+
version: 11.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Savage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|