public
Description: A Relational Algebra
Clone URL: git://github.com/nkallen/arel.git
Click here to lend your support to: arel and make a donation at www.pledgie.com !
moved bind to factory of select
Nick Kallen (author)
Fri Apr 11 13:47:06 -0700 2008
commit  42c42bfa50876b4221c024cebc47fc34fc6530a9
tree    73777a9c4f61330bd89832b312318ffb555afaca
parent  89b354bf97d0a981376d36f2f8a7ba6a87fe2aa8
...
1
2
3
4
5
...
1
 
2
3
4
0
@@ -1,5 +1,4 @@
0
 require 'rubygems'
0
-require 'spec'
0
 require 'spec/rake/spectask'
0
 
0
 Spec::Rake::SpecTask.new do |t|
...
46
47
48
49
50
51
 
52
53
54
55
56
57
 
58
59
60
61
62
63
 
64
65
66
67
68
69
 
70
71
72
...
74
75
76
77
78
79
 
80
81
82
...
46
47
48
 
 
 
49
50
51
52
 
 
 
53
54
55
56
 
 
 
57
58
59
60
 
 
 
61
62
63
64
...
66
67
68
 
 
 
69
70
71
72
0
@@ -46,27 +46,19 @@ module ActiveRelation
0
   end
0
 
0
   class GreaterThanOrEqualTo < Binary
0
- def predicate_sql
0
- '>='
0
- end
0
+ def predicate_sql; '>=' end
0
   end
0
 
0
   class GreaterThan < Binary
0
- def predicate_sql
0
- '>'
0
- end
0
+ def predicate_sql; '>' end
0
   end
0
 
0
   class LessThanOrEqualTo < Binary
0
- def predicate_sql
0
- '<='
0
- end
0
+ def predicate_sql; '<=' end
0
   end
0
 
0
   class LessThan < Binary
0
- def predicate_sql
0
- '<'
0
- end
0
+ def predicate_sql; '<' end
0
   end
0
 
0
   class Match < Binary
0
@@ -74,8 +66,6 @@ module ActiveRelation
0
   end
0
   
0
   class In < Binary
0
- def predicate_sql
0
- operand2.inclusion_predicate_sql
0
- end
0
+ def predicate_sql; operand2.inclusion_predicate_sql end
0
   end
0
 end
0
\ No newline at end of file
...
38
39
40
41
 
42
43
44
...
38
39
40
 
41
42
43
44
0
@@ -38,7 +38,7 @@ module ActiveRelation
0
       end
0
 
0
       def select(*predicates)
0
- Selection.new(self, *predicates.collect {|p| p.bind(self)})
0
+ Selection.new(self, *predicates)
0
       end
0
 
0
       def project(*attributes)
...
3
4
5
6
 
7
 
8
9
10
...
3
4
5
 
6
7
8
9
10
11
0
@@ -3,8 +3,9 @@ module ActiveRelation
0
     attr_reader :predicate
0
 
0
     def initialize(relation, *predicates)
0
- @predicate = predicates.shift
0
+ predicate = predicates.shift
0
       @relation = predicates.empty?? relation : Selection.new(relation, *predicates)
0
+ @predicate = predicate.bind(@relation)
0
     end
0
 
0
     def ==(other)
...
91
92
93
94
 
95
96
97
...
91
92
93
 
94
95
96
97
0
@@ -91,7 +91,7 @@ module ActiveRelation
0
         end
0
     
0
         it "accepts arbitrary strings" do
0
- @relation.select("arbitrary").should == Selection.new(@relation, Value.new("arbitrary", @relation))
0
+ @relation.select("arbitrary").should == Selection.new(@relation, "arbitrary")
0
         end
0
       end
0
   
...
26
27
28
 
 
 
 
29
30
31
 
 
32
33
34
...
45
46
47
48
 
49
50
51
...
26
27
28
29
30
31
32
33
 
 
34
35
36
37
38
...
49
50
51
 
52
53
54
55
0
@@ -26,9 +26,13 @@ module ActiveRelation
0
     end
0
 
0
     describe '#descend' do
0
+ before do
0
+ @selection = Selection.new(@relation, @predicate)
0
+ end
0
+
0
       it "distributes a block over the relation and predicates" do
0
- Selection.new(@relation, @predicate).descend(&:qualify). \
0
- should == Selection.new(@relation.descend(&:qualify), @predicate.descend(&:qualify))
0
+ @selection.descend(&:qualify). \
0
+ should == Selection.new(@selection.relation.descend(&:qualify), @selection.predicate.qualify)
0
       end
0
     end
0
   
0
@@ -45,7 +49,7 @@ module ActiveRelation
0
       
0
       describe 'when given a string' do
0
         before do
0
- @string = "asdf".bind(@relation)
0
+ @string = "asdf"
0
         end
0
         
0
         it "passes the string through to the where clause" do

Comments

    No one has commented yet.