composite_primary_keys 10.0.0 → 10.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d393427145f3047288fffba8fc3434fa41518f4e
4
- data.tar.gz: f828598d6e09660c798a7735510c5130084b85b9
3
+ metadata.gz: ec792a1a934ab5a71880968f63579a5f4558ee3c
4
+ data.tar.gz: b253ff76697c55e458afdb2fff11d12356cf008d
5
5
  SHA512:
6
- metadata.gz: fb6c3cfc3c74ddd3eca736945a5e70cebc2a093e704d0407cbe2983670be5282958cffa24507069e623b1099984fceeb02864b55a76d29c3712bcfac91686a58
7
- data.tar.gz: eeef7b365078357a92b2167f200458bde725b3b3e2032bb17d0799bd19a02e93314e758f89dcf97144d3d39a315cb22fa2120f9848d3496f9f2355190c447dd2
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.where(table.name => { key => value })
34
- mappings = Array(key).zip(Array(foreign_key))
35
- joins = mappings.reduce(Hash.new) do |hash, mapping|
36
- hash[mapping.first] = transform_value(owner[mapping.last])
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.where(table.name => { reflection.type => polymorphic_type })
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.where(table.name => { reflection.type => value })
57
+ scope = apply_scope(scope, table, reflection.type, value)
61
58
  end
62
59
 
63
- scope = scope.joins(join(foreign_table, constraint))
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
@@ -2,7 +2,7 @@ module CompositePrimaryKeys
2
2
  module VERSION
3
3
  MAJOR = 10
4
4
  MINOR = 0
5
- TINY = 0
5
+ TINY = 1
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
8
  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.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-08 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord