composite_primary_keys 12.0.0.rc1 → 12.0.0.rc2
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2de0c70c7a4c4075ec01794087047e1ce9b8f3f72e6c02450519d9b240322a98
|
4
|
+
data.tar.gz: d87673437c48ed131cbeb39e20a477f1125ba1515dcb59de729e9c5567281e93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4b2d8dcd63be551a19ae50f6acc810506cfffd06c8e2b60e6a6d2461a671d0cab7a4226dbdb2affdb7271d9bab776379343afadc6feb6fdfac4b12949ac10b5
|
7
|
+
data.tar.gz: 4c0cbfde4dec1c2e7cbee6f0195da429af01917426dfd1dd9fae8eee9a94de48eca75943665e01c3ccfd21ff58ea2d811259722ca0a45e32957ce41d2f605d83
|
@@ -1,20 +1,6 @@
|
|
1
1
|
module Arel
|
2
2
|
module Visitors
|
3
3
|
class ToSql
|
4
|
-
# def visit_Arel_Nodes_In o, collector
|
5
|
-
# if Array === o.right && o.right.empty?
|
6
|
-
# collector << '1=0'
|
7
|
-
# else
|
8
|
-
# # CPK
|
9
|
-
# collector << "("
|
10
|
-
# collector = visit o.left, collector
|
11
|
-
# # CPK
|
12
|
-
# collector << ")"
|
13
|
-
# collector << " IN ("
|
14
|
-
# visit(o.right, collector) << ")"
|
15
|
-
# end
|
16
|
-
# end
|
17
|
-
|
18
4
|
def visit_CompositePrimaryKeys_CompositeKeys o, collector
|
19
5
|
values = o.map do |key|
|
20
6
|
case key
|
@@ -24,7 +10,7 @@ module Arel
|
|
24
10
|
key
|
25
11
|
end
|
26
12
|
end
|
27
|
-
collector << "#{values.join(', ')}"
|
13
|
+
collector << "(#{values.join(', ')})"
|
28
14
|
collector
|
29
15
|
end
|
30
16
|
end
|
@@ -25,22 +25,23 @@ module ActiveRecord
|
|
25
25
|
end
|
26
26
|
|
27
27
|
stmt = Arel::UpdateManager.new
|
28
|
+
stmt.table(arel.join_sources.empty? ? table : arel.source)
|
28
29
|
if @klass.composite?
|
29
|
-
|
30
|
+
stmt.table(table)
|
31
|
+
subselect = arel.clone
|
32
|
+
arel_attributes = primary_keys.map do |key|
|
30
33
|
arel_attribute(key)
|
31
34
|
end.to_composite_keys
|
32
|
-
subselect =
|
33
|
-
|
34
|
-
stmt.table(table)
|
35
|
-
stmt.key = arel_attributes.in(subselect)
|
35
|
+
subselect.projections = arel_attributes
|
36
|
+
stmt.wheres = [arel_attributes.in(subselect)]
|
36
37
|
else
|
37
38
|
stmt.table(arel.join_sources.empty? ? table : arel.source)
|
38
39
|
stmt.key = arel_attribute(primary_key)
|
40
|
+
stmt.wheres = arel.constraints
|
39
41
|
end
|
40
42
|
stmt.take(arel.limit)
|
41
43
|
stmt.offset(arel.offset)
|
42
44
|
stmt.order(*arel.orders)
|
43
|
-
stmt.wheres = arel.constraints
|
44
45
|
|
45
46
|
if updates.is_a?(Hash)
|
46
47
|
if klass.locking_enabled? &&
|
data/test/test_update.rb
CHANGED
@@ -67,10 +67,13 @@ class TestUpdate < ActiveSupport::TestCase
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_update_all_join
|
70
|
-
ReferenceCode.joins(:reference_type).
|
70
|
+
ReferenceCode.joins(:reference_type).
|
71
|
+
where('reference_types.reference_type_id = ?', 2).
|
72
|
+
update_all(:description => 'random value')
|
71
73
|
|
72
|
-
ReferenceCode.
|
73
|
-
|
74
|
-
|
74
|
+
query = ReferenceCode.where('reference_type_id = ?', 2).
|
75
|
+
where(:description => 'random value')
|
76
|
+
|
77
|
+
assert_equal(2, query.count)
|
75
78
|
end
|
76
|
-
end
|
79
|
+
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: 12.0.0.
|
4
|
+
version: 12.0.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Savage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|