composite_primary_keys 4.0.0.beta5 → 4.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 4.0.0.beta6 2011-07-26
2
+ * Compatible with Rails 3.1 RC5 (TycoooN)
3
+ * Do not use Arel::Nodes::Or to combine predicates because it creates a
4
+ deeply nested stack that blows up.
5
+
1
6
  == 4.0.0.beta4 2011-07-22
2
7
  * Compatible with Rails 3.1 stable branch. No longer works with RC4 (Charlie Savage)
3
8
  * Do not require loading of postgresql gem unless needed (Charlie Savage)
@@ -26,7 +26,7 @@ $:.unshift(File.dirname(__FILE__)) unless
26
26
 
27
27
  unless defined?(ActiveRecord)
28
28
  require 'rubygems'
29
- gem 'activerecord', '~> 3.1.0.rc4'
29
+ gem 'activerecord', '= 3.1.0.rc5'
30
30
  require 'active_record'
31
31
  end
32
32
 
@@ -9,11 +9,11 @@ module CompositePrimaryKeys
9
9
  end
10
10
 
11
11
  def cpk_or_predicate(predicates)
12
- result = predicates.shift
13
- predicates.each do |predicate|
14
- result = result.or(predicate)
15
- end
16
- result
12
+ # Can't do or here, arel does the wrong thing and makes a really
13
+ # deeply nested stack that blows up
14
+ predicates.map do |predicate|
15
+ predicate.to_sql
16
+ end.join(" OR ")
17
17
  end
18
18
 
19
19
  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, 'beta5'].join('.')
6
+ STRING = [MAJOR, MINOR, TINY, 'beta6'].join('.')
7
7
  end
8
8
  end
@@ -0,0 +1,35 @@
1
+ require 'abstract_unit'
2
+
3
+ class TestEqual < ActiveSupport::TestCase
4
+ fixtures :departments
5
+
6
+ include CompositePrimaryKeys::Predicates
7
+
8
+ def test_or
9
+ dep = Arel::Table.new(:departments)
10
+
11
+ predicates = Array.new
12
+
13
+ 5.times do |i|
14
+ predicates << dep[:id].eq(i)
15
+ end
16
+
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',
19
+ pred)
20
+ end
21
+
22
+ def test_and
23
+ dep = Arel::Table.new(:departments)
24
+
25
+ predicates = Array.new
26
+
27
+ 5.times do |i|
28
+ predicates << dep[:id].eq(i)
29
+ end
30
+
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',
33
+ pred.to_sql)
34
+ end
35
+ end
@@ -15,6 +15,7 @@ require 'test_ids'
15
15
  require 'test_miscellaneous'
16
16
  require 'test_pagination'
17
17
  require 'test_polymorphic'
18
+ require 'test_predicates'
18
19
  require 'test_santiago'
19
20
  require 'test_tutorial_example'
20
21
  require 'test_update'
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: 62196265
4
+ hash: 62196271
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 4
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 5
12
- version: 4.0.0.beta5
11
+ - 6
12
+ version: 4.0.0.beta6
13
13
  platform: ruby
14
14
  authors:
15
15
  - Dr Nic Williams
@@ -26,16 +26,16 @@ dependencies:
26
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
27
  none: false
28
28
  requirements:
29
- - - ~>
29
+ - - "="
30
30
  - !ruby/object:Gem::Version
31
- hash: 15424109
31
+ hash: 15424111
32
32
  segments:
33
33
  - 3
34
34
  - 1
35
35
  - 0
36
36
  - rc
37
- - 4
38
- version: 3.1.0.rc4
37
+ - 5
38
+ version: 3.1.0.rc5
39
39
  type: :runtime
40
40
  version_requirements: *id001
41
41
  description: Composite key support for ActiveRecord 3
@@ -184,6 +184,7 @@ files:
184
184
  - test/test_miscellaneous.rb
185
185
  - test/test_pagination.rb
186
186
  - test/test_polymorphic.rb
187
+ - test/test_predicates.rb
187
188
  - test/test_santiago.rb
188
189
  - test/test_suite.rb
189
190
  - test/test_tutorial_example.rb
@@ -248,6 +249,7 @@ test_files:
248
249
  - test/test_miscellaneous.rb
249
250
  - test/test_pagination.rb
250
251
  - test/test_polymorphic.rb
252
+ - test/test_predicates.rb
251
253
  - test/test_santiago.rb
252
254
  - test/test_suite.rb
253
255
  - test/test_tutorial_example.rb