composite_primary_keys 4.0.0.beta6 → 4.0.0.beta7
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.
data/History.txt
CHANGED
@@ -11,9 +11,11 @@ module CompositePrimaryKeys
|
|
11
11
|
def cpk_or_predicate(predicates)
|
12
12
|
# Can't do or here, arel does the wrong thing and makes a really
|
13
13
|
# deeply nested stack that blows up
|
14
|
-
predicates.map do |predicate|
|
15
|
-
predicate.to_sql
|
16
|
-
end
|
14
|
+
predicates = predicates.map do |predicate|
|
15
|
+
"(#{predicate.to_sql})"
|
16
|
+
end
|
17
|
+
predicates = "(#{predicates.join(" OR ")})"
|
18
|
+
Arel::Nodes::SqlLiteral.new(predicates)
|
17
19
|
end
|
18
20
|
|
19
21
|
def cpk_id_predicate(table, keys, values)
|
data/test/fixtures/products.yml
CHANGED
data/test/test_habtm.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'abstract_unit'
|
2
|
-
require 'ruby-debug'
|
3
2
|
|
4
3
|
class TestHabtm < ActiveSupport::TestCase
|
5
|
-
|
6
4
|
fixtures :suburbs, :restaurants, :restaurants_suburbs, :products
|
7
5
|
|
8
6
|
def test_has_and_belongs_to_many
|
@@ -107,10 +105,9 @@ class TestHabtm < ActiveSupport::TestCase
|
|
107
105
|
|
108
106
|
# reload to force reload of associations
|
109
107
|
product_one = Product.find(1)
|
108
|
+
assert_equal 2, product_one.restaurants.size
|
109
|
+
|
110
110
|
product_three = Product.find(3)
|
111
|
-
|
112
111
|
assert_equal 0, product_three.restaurants.size
|
113
|
-
assert_equal 2, product_one.restaurants.size
|
114
112
|
end
|
115
|
-
|
116
113
|
end
|
data/test/test_predicates.rb
CHANGED
@@ -10,12 +10,12 @@ class TestEqual < ActiveSupport::TestCase
|
|
10
10
|
|
11
11
|
predicates = Array.new
|
12
12
|
|
13
|
-
|
13
|
+
3.times do |i|
|
14
14
|
predicates << dep[:id].eq(i)
|
15
15
|
end
|
16
16
|
|
17
17
|
pred = cpk_or_predicate(predicates)
|
18
|
-
assert_equal('"departments"."id" = 0 OR "departments"."id" = 1 OR "departments"."id" = 2
|
18
|
+
assert_equal('(("departments"."id" = 0) OR ("departments"."id" = 1) OR ("departments"."id" = 2))',
|
19
19
|
pred)
|
20
20
|
end
|
21
21
|
|
@@ -24,12 +24,12 @@ class TestEqual < ActiveSupport::TestCase
|
|
24
24
|
|
25
25
|
predicates = Array.new
|
26
26
|
|
27
|
-
|
27
|
+
3.times do |i|
|
28
28
|
predicates << dep[:id].eq(i)
|
29
29
|
end
|
30
30
|
|
31
31
|
pred = cpk_and_predicate(predicates)
|
32
|
-
assert_equal('"departments"."id" = 0 AND "departments"."id" = 1 AND "departments"."id" = 2
|
32
|
+
assert_equal('"departments"."id" = 0 AND "departments"."id" = 1 AND "departments"."id" = 2',
|
33
33
|
pred.to_sql)
|
34
34
|
end
|
35
35
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: composite_primary_keys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196269
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 4
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 4.0.0.
|
11
|
+
- 7
|
12
|
+
version: 4.0.0.beta7
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Dr Nic Williams
|