composite_primary_keys 4.0.0.beta6 → 4.0.0.beta7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- == 4.0.0.beta6 2011-07-26
1
+ == 4.0.0.beta7 2011-07-26
2
2
  * Compatible with Rails 3.1 RC5 (TycoooN)
3
3
  * Do not use Arel::Nodes::Or to combine predicates because it creates a
4
4
  deeply nested stack that blows up.
@@ -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.join(" OR ")
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)
@@ -3,6 +3,6 @@ module CompositePrimaryKeys
3
3
  MAJOR = 4
4
4
  MINOR = 0
5
5
  TINY = 0
6
- STRING = [MAJOR, MINOR, TINY, 'beta6'].join('.')
6
+ STRING = [MAJOR, MINOR, TINY, 'beta7'].join('.')
7
7
  end
8
8
  end
@@ -1,9 +1,11 @@
1
1
  first_product:
2
2
  id: 1
3
3
  name: Product One
4
+
4
5
  second_product:
5
6
  id: 2
6
7
  name: Product Two
8
+
7
9
  third_product:
8
10
  id: 3
9
11
  name: Product Three
@@ -2,10 +2,12 @@ mcdonalds:
2
2
  franchise_id: 1
3
3
  store_id: 1
4
4
  name: McDonalds
5
+
5
6
  subway_one:
6
7
  franchise_id: 2
7
8
  store_id: 1
8
9
  name: Subway 1
10
+
9
11
  subway_two:
10
12
  franchise_id: 2
11
13
  store_id: 2
@@ -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
@@ -10,12 +10,12 @@ class TestEqual < ActiveSupport::TestCase
10
10
 
11
11
  predicates = Array.new
12
12
 
13
- 5.times do |i|
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 OR "departments"."id" = 3 OR "departments"."id" = 4',
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
- 5.times do |i|
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 AND "departments"."id" = 3 AND "departments"."id" = 4',
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: 62196271
4
+ hash: 62196269
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 4
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 6
12
- version: 4.0.0.beta6
11
+ - 7
12
+ version: 4.0.0.beta7
13
13
  platform: ruby
14
14
  authors:
15
15
  - Dr Nic Williams