composite_primary_keys 10.0.0 → 10.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec792a1a934ab5a71880968f63579a5f4558ee3c
|
4
|
+
data.tar.gz: b253ff76697c55e458afdb2fff11d12356cf008d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd9b2cfd6098aa20094306f7605bfce2332834e97a4b50c073d124d6a1bee19ded28854a8ea27e3ff2f50ae1745bf2e320fafd54fd6d70c4a8b9fa9643017779
|
7
|
+
data.tar.gz: 350b8a33f062bef98f21e419ed229124705d2ccca8303c47ada9528cd8522d691d1af138c7534e49fe869c317810249b2c3c24aa138cf110dbf1cae401595764
|
data/History.rdoc
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 10.0.1 (2017-10-08)
|
2
|
+
|
3
|
+
* Fixed an error that happened when a table attribute had the same name as the table (Taishi Kasuga)
|
4
|
+
|
1
5
|
== 10.0.0 (2017-10-08)
|
2
6
|
|
3
7
|
* Support ActiveRecord 5.1.x (Pinak Thakkar, Jordan Owens)
|
@@ -5,6 +9,10 @@
|
|
5
9
|
* Fix typo in Readme (Mike Gunderloy)
|
6
10
|
* Improved sql server support (Artyom Nikolaev)
|
7
11
|
|
12
|
+
== 9.0.8 (2017-10-11)
|
13
|
+
|
14
|
+
* Fix Paper Trail compatibility (Sean Linsley)
|
15
|
+
|
8
16
|
== 9.0.7 (2017-05-22)
|
9
17
|
|
10
18
|
* Update sqlite3 to support deletes and updates (Charlie Savage)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module Associations
|
3
3
|
class AssociationScope
|
4
|
-
|
5
4
|
def self.get_bind_values(owner, chain)
|
6
5
|
binds = []
|
7
6
|
last_reflection = chain.last
|
@@ -29,18 +28,16 @@ module ActiveRecord
|
|
29
28
|
foreign_key = join_keys.foreign_key
|
30
29
|
|
31
30
|
# CPK
|
32
|
-
#value = transform_value(owner[foreign_key])
|
33
|
-
#scope = scope
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
hash
|
31
|
+
# value = transform_value(owner[foreign_key])
|
32
|
+
# scope = apply_scope(scope, table, key, value)
|
33
|
+
Array(key).zip(Array(foreign_key)).each do |a_join_key, a_foreign_key|
|
34
|
+
value = transform_value(owner[a_foreign_key])
|
35
|
+
scope = apply_scope(scope, table, a_join_key, value)
|
38
36
|
end
|
39
|
-
scope = scope.where(table.name => joins)
|
40
37
|
|
41
38
|
if reflection.type
|
42
39
|
polymorphic_type = transform_value(owner.class.base_class.name)
|
43
|
-
scope = scope
|
40
|
+
scope = apply_scope(scope, table, reflection.type, polymorphic_type)
|
44
41
|
end
|
45
42
|
|
46
43
|
scope
|
@@ -57,11 +54,11 @@ module ActiveRecord
|
|
57
54
|
|
58
55
|
if reflection.type
|
59
56
|
value = transform_value(next_reflection.klass.base_class.name)
|
60
|
-
scope = scope
|
57
|
+
scope = apply_scope(scope, table, reflection.type, value)
|
61
58
|
end
|
62
59
|
|
63
|
-
scope
|
60
|
+
scope.joins!(join(foreign_table, constraint))
|
64
61
|
end
|
65
62
|
end
|
66
63
|
end
|
67
|
-
end
|
64
|
+
end
|
@@ -1,33 +1,33 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
class PredicateBuilder
|
3
|
-
class AssociationQueryHandler
|
4
|
-
def call(attribute, value)
|
5
|
-
queries = {}
|
6
|
-
|
7
|
-
table = value.associated_table
|
8
|
-
if value.base_class
|
9
|
-
queries[table.association_foreign_type.to_s] = value.base_class.name
|
10
|
-
end
|
11
|
-
|
12
|
-
# CPK
|
13
|
-
# queries[table.association_foreign_key.to_s] = value.ids
|
14
|
-
# predicate_builder.build_from_hash(queries)
|
15
|
-
if table.association_foreign_key.is_a?(Array)
|
16
|
-
values = case value.value
|
17
|
-
when Relation
|
18
|
-
value.ids.map {|record| record.ids}
|
19
|
-
when Array
|
20
|
-
value.ids
|
21
|
-
else
|
22
|
-
[value.ids]
|
23
|
-
end
|
24
|
-
|
25
|
-
CompositePrimaryKeys::Predicates.cpk_in_predicate(attribute.relation, table.association_foreign_key, values)
|
26
|
-
else
|
27
|
-
queries[table.association_foreign_key.to_s] = value.ids
|
28
|
-
predicate_builder.build_from_hash(queries)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
1
|
+
module ActiveRecord
|
2
|
+
class PredicateBuilder
|
3
|
+
class AssociationQueryHandler
|
4
|
+
def call(attribute, value)
|
5
|
+
queries = {}
|
6
|
+
|
7
|
+
table = value.associated_table
|
8
|
+
if value.base_class
|
9
|
+
queries[table.association_foreign_type.to_s] = value.base_class.name
|
10
|
+
end
|
11
|
+
|
12
|
+
# CPK
|
13
|
+
# queries[table.association_foreign_key.to_s] = value.ids
|
14
|
+
# predicate_builder.build_from_hash(queries)
|
15
|
+
if table.association_foreign_key.is_a?(Array)
|
16
|
+
values = case value.value
|
17
|
+
when Relation
|
18
|
+
value.ids.map {|record| record.ids}
|
19
|
+
when Array
|
20
|
+
value.ids
|
21
|
+
else
|
22
|
+
[value.ids]
|
23
|
+
end
|
24
|
+
|
25
|
+
CompositePrimaryKeys::Predicates.cpk_in_predicate(attribute.relation, table.association_foreign_key, values)
|
26
|
+
else
|
27
|
+
queries[table.association_foreign_key.to_s] = value.ids
|
28
|
+
predicate_builder.build_from_hash(queries)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
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: 10.0.
|
4
|
+
version: 10.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Savage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|