veritas-sql-generator 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. data/.travis.yml +4 -2
  2. data/Gemfile +8 -9
  3. data/README.rdoc +17 -0
  4. data/Rakefile +2 -2
  5. data/TODO +0 -2
  6. data/lib/veritas/sql/generator/version.rb +1 -1
  7. data/spec/spec_helper.rb +2 -1
  8. data/spec/unit/veritas/sql/generator/literal/visit_time_spec.rb +2 -2
  9. data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_join_spec.rb +10 -10
  10. data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_product_spec.rb +18 -18
  11. data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_difference_spec.rb +10 -10
  12. data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_intersection_spec.rb +10 -10
  13. data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_union_spec.rb +10 -10
  14. data/spec/unit/veritas/sql/generator/relation/unary/to_s_spec.rb +3 -3
  15. data/spec/unit/veritas/sql/generator/relation/unary/to_subquery_spec.rb +3 -3
  16. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_extension_spec.rb +10 -10
  17. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_projection_spec.rb +12 -12
  18. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_rename_spec.rb +12 -12
  19. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_restriction_spec.rb +17 -17
  20. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_summarization_spec.rb +49 -49
  21. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_limit_spec.rb +18 -18
  22. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb +18 -18
  23. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb +21 -14
  24. data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_reverse_spec.rb +18 -18
  25. data/tasks/metrics/heckle.rake +1 -0
  26. data/veritas-sql-generator.gemspec +17 -17
  27. metadata +33 -33
@@ -54,7 +54,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_union' do
54
54
  end
55
55
 
56
56
  context 'when the operands are restrictions' do
57
- let(:operand) { base_relation.restrict { |r| r[:id].eq(1) } }
57
+ let(:operand) { base_relation.restrict { |r| r.id.eq(1) } }
58
58
 
59
59
  it_should_behave_like 'a generated SQL SELECT query'
60
60
 
@@ -64,8 +64,8 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_union' do
64
64
 
65
65
  context 'when the operand is a summarization' do
66
66
  context 'summarize per table dee' do
67
- let(:summarize_per) { TABLE_DEE }
68
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
67
+ let(:summarize_per) { TABLE_DEE }
68
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
69
69
 
70
70
  it_should_behave_like 'a generated SQL SELECT query'
71
71
 
@@ -74,8 +74,8 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_union' do
74
74
  end
75
75
 
76
76
  context 'summarize per table dum' do
77
- let(:summarize_per) { TABLE_DUM }
78
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
77
+ let(:summarize_per) { TABLE_DUM }
78
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
79
79
 
80
80
  it_should_behave_like 'a generated SQL SELECT query'
81
81
 
@@ -84,7 +84,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_union' do
84
84
  end
85
85
 
86
86
  context 'summarize by a subset of the operand header' do
87
- let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r[:age].count) } }
87
+ let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) } }
88
88
 
89
89
  it_should_behave_like 'a generated SQL SELECT query'
90
90
 
@@ -94,7 +94,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_union' do
94
94
  end
95
95
 
96
96
  context 'when the operand is ordered' do
97
- let(:operand) { base_relation.order }
97
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
98
98
 
99
99
  it_should_behave_like 'a generated SQL SELECT query'
100
100
 
@@ -103,7 +103,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_union' do
103
103
  end
104
104
 
105
105
  context 'when the operand is reversed' do
106
- let(:operand) { base_relation.order.reverse }
106
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.reverse }
107
107
 
108
108
  it_should_behave_like 'a generated SQL SELECT query'
109
109
 
@@ -112,7 +112,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_union' do
112
112
  end
113
113
 
114
114
  context 'when the operand is limited' do
115
- let(:operand) { base_relation.order.take(1) }
115
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.take(1) }
116
116
 
117
117
  it_should_behave_like 'a generated SQL SELECT query'
118
118
 
@@ -121,7 +121,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_union' do
121
121
  end
122
122
 
123
123
  context 'when the operands are offsets' do
124
- let(:operand) { base_relation.order.drop(1) }
124
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1) }
125
125
 
126
126
  it_should_behave_like 'a generated SQL SELECT query'
127
127
 
@@ -25,7 +25,7 @@ describe SQL::Generator::Relation::Unary, '#to_s' do
25
25
 
26
26
  context 'when a restriction is visited' do
27
27
  before do
28
- object.visit(base_relation.restrict { |r| r[:id].eq(1) })
28
+ object.visit(base_relation.restrict { |r| r.id.eq(1) })
29
29
  end
30
30
 
31
31
  it_should_behave_like 'a generated SQL expression'
@@ -35,7 +35,7 @@ describe SQL::Generator::Relation::Unary, '#to_s' do
35
35
 
36
36
  context 'when a limit is visited' do
37
37
  before do
38
- object.visit(base_relation.order.take(1))
38
+ object.visit(base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.take(1))
39
39
  end
40
40
 
41
41
  it_should_behave_like 'a generated SQL expression'
@@ -45,7 +45,7 @@ describe SQL::Generator::Relation::Unary, '#to_s' do
45
45
 
46
46
  context 'when an offset is visited' do
47
47
  before do
48
- object.visit(base_relation.order.drop(1))
48
+ object.visit(base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1))
49
49
  end
50
50
 
51
51
  it_should_behave_like 'a generated SQL expression'
@@ -45,7 +45,7 @@ describe SQL::Generator::Relation::Unary, '#to_subquery' do
45
45
 
46
46
  context 'when a restriction is visited' do
47
47
  before do
48
- object.visit(base_relation.restrict { |r| r[:id].eq(1) })
48
+ object.visit(base_relation.restrict { |r| r.id.eq(1) })
49
49
  end
50
50
 
51
51
  it_should_behave_like 'a generated SQL expression'
@@ -55,7 +55,7 @@ describe SQL::Generator::Relation::Unary, '#to_subquery' do
55
55
 
56
56
  context 'when a limit is visited' do
57
57
  before do
58
- object.visit(base_relation.order.take(1))
58
+ object.visit(base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.take(1))
59
59
  end
60
60
 
61
61
  it_should_behave_like 'a generated SQL expression'
@@ -65,7 +65,7 @@ describe SQL::Generator::Relation::Unary, '#to_subquery' do
65
65
 
66
66
  context 'when an offset is visited' do
67
67
  before do
68
- object.visit(base_relation.order.drop(1))
68
+ object.visit(base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1))
69
69
  end
70
70
 
71
71
  it_should_behave_like 'a generated SQL expression'
@@ -52,7 +52,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_extension' do
52
52
  end
53
53
 
54
54
  context 'when the operand is a restriction' do
55
- let(:operand) { base_relation.restrict { |r| r[:id].eq(1) } }
55
+ let(:operand) { base_relation.restrict { |r| r.id.eq(1) } }
56
56
 
57
57
  it_should_behave_like 'a generated SQL SELECT query'
58
58
 
@@ -62,8 +62,8 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_extension' do
62
62
 
63
63
  context 'when the operand is a summarization' do
64
64
  context 'summarize per table dee' do
65
- let(:summarize_per) { TABLE_DEE }
66
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
65
+ let(:summarize_per) { TABLE_DEE }
66
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
67
67
 
68
68
  it_should_behave_like 'a generated SQL SELECT query'
69
69
 
@@ -72,8 +72,8 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_extension' do
72
72
  end
73
73
 
74
74
  context 'summarize per table dum' do
75
- let(:summarize_per) { TABLE_DUM }
76
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
75
+ let(:summarize_per) { TABLE_DUM }
76
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
77
77
 
78
78
  it_should_behave_like 'a generated SQL SELECT query'
79
79
 
@@ -82,7 +82,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_extension' do
82
82
  end
83
83
 
84
84
  context 'summarize by a subset of the operand header' do
85
- let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r[:age].count) } }
85
+ let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) } }
86
86
 
87
87
  it_should_behave_like 'a generated SQL SELECT query'
88
88
 
@@ -92,7 +92,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_extension' do
92
92
  end
93
93
 
94
94
  context 'when the operand is ordered' do
95
- let(:operand) { base_relation.order }
95
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
96
96
 
97
97
  it_should_behave_like 'a generated SQL SELECT query'
98
98
 
@@ -101,7 +101,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_extension' do
101
101
  end
102
102
 
103
103
  context 'when the operand is reversed' do
104
- let(:operand) { base_relation.order.reverse }
104
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.reverse }
105
105
 
106
106
  it_should_behave_like 'a generated SQL SELECT query'
107
107
 
@@ -110,7 +110,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_extension' do
110
110
  end
111
111
 
112
112
  context 'when the operand is limited' do
113
- let(:operand) { base_relation.order.take(1) }
113
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.take(1) }
114
114
 
115
115
  it_should_behave_like 'a generated SQL SELECT query'
116
116
 
@@ -119,7 +119,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_extension' do
119
119
  end
120
120
 
121
121
  context 'when the operand is an offset' do
122
- let(:operand) { base_relation.order.drop(1) }
122
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1) }
123
123
 
124
124
  it_should_behave_like 'a generated SQL SELECT query'
125
125
 
@@ -78,7 +78,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_projection' do
78
78
  end
79
79
 
80
80
  context 'when the operand is a restriction' do
81
- let(:operand) { base_relation.restrict { |r| r[:id].eq(1) } }
81
+ let(:operand) { base_relation.restrict { |r| r.id.eq(1) } }
82
82
 
83
83
  it_should_behave_like 'a generated SQL SELECT query'
84
84
 
@@ -88,9 +88,9 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_projection' do
88
88
 
89
89
  context 'when the operand is a summarization' do
90
90
  context 'summarize per table dee' do
91
- let(:summarize_per) { TABLE_DEE }
92
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
93
- let(:projection) { operand.project([ :count ]) }
91
+ let(:summarize_per) { TABLE_DEE }
92
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
93
+ let(:projection) { operand.project([ :count ]) }
94
94
 
95
95
  it_should_behave_like 'a generated SQL SELECT query'
96
96
 
@@ -99,9 +99,9 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_projection' do
99
99
  end
100
100
 
101
101
  context 'summarize per table dum' do
102
- let(:summarize_per) { TABLE_DUM }
103
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
104
- let(:projection) { operand.project([ :count ]) }
102
+ let(:summarize_per) { TABLE_DUM }
103
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
104
+ let(:projection) { operand.project([ :count ]) }
105
105
 
106
106
  it_should_behave_like 'a generated SQL SELECT query'
107
107
 
@@ -110,7 +110,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_projection' do
110
110
  end
111
111
 
112
112
  context 'summarize by a subset of the operand header' do
113
- let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r[:age].count) } }
113
+ let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) } }
114
114
 
115
115
  it_should_behave_like 'a generated SQL SELECT query'
116
116
 
@@ -120,7 +120,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_projection' do
120
120
  end
121
121
 
122
122
  context 'when the operand is ordered' do
123
- let(:operand) { base_relation.order }
123
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
124
124
 
125
125
  it_should_behave_like 'a generated SQL SELECT query'
126
126
 
@@ -129,7 +129,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_projection' do
129
129
  end
130
130
 
131
131
  context 'when the operand is reversed' do
132
- let(:operand) { base_relation.order.reverse }
132
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.reverse }
133
133
 
134
134
  it_should_behave_like 'a generated SQL SELECT query'
135
135
 
@@ -138,7 +138,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_projection' do
138
138
  end
139
139
 
140
140
  context 'when the operand is limited' do
141
- let(:operand) { base_relation.order.take(1) }
141
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.take(1) }
142
142
 
143
143
  it_should_behave_like 'a generated SQL SELECT query'
144
144
 
@@ -147,7 +147,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_projection' do
147
147
  end
148
148
 
149
149
  context 'when the operand is an offset' do
150
- let(:operand) { base_relation.order.drop(1) }
150
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1) }
151
151
 
152
152
  it_should_behave_like 'a generated SQL SELECT query'
153
153
 
@@ -63,7 +63,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_rename' do
63
63
  end
64
64
 
65
65
  context 'when the operand is a restriction' do
66
- let(:operand) { base_relation.restrict { |r| r[:id].eq(1) } }
66
+ let(:operand) { base_relation.restrict { |r| r.id.eq(1) } }
67
67
 
68
68
  it_should_behave_like 'a generated SQL SELECT query'
69
69
 
@@ -73,9 +73,9 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_rename' do
73
73
 
74
74
  context 'when the operand is a summarization' do
75
75
  context 'summarize per table dee' do
76
- let(:summarize_per) { TABLE_DEE }
77
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
78
- let(:rename) { operand.rename(:count => :other_count) }
76
+ let(:summarize_per) { TABLE_DEE }
77
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
78
+ let(:rename) { operand.rename(:count => :other_count) }
79
79
 
80
80
  it_should_behave_like 'a generated SQL SELECT query'
81
81
 
@@ -84,9 +84,9 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_rename' do
84
84
  end
85
85
 
86
86
  context 'summarize per table dum' do
87
- let(:summarize_per) { TABLE_DUM }
88
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
89
- let(:rename) { operand.rename(:count => :other_count) }
87
+ let(:summarize_per) { TABLE_DUM }
88
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
89
+ let(:rename) { operand.rename(:count => :other_count) }
90
90
 
91
91
  it_should_behave_like 'a generated SQL SELECT query'
92
92
 
@@ -95,7 +95,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_rename' do
95
95
  end
96
96
 
97
97
  context 'summarize by a subset of the operand header' do
98
- let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r[:age].count) } }
98
+ let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) } }
99
99
 
100
100
  it_should_behave_like 'a generated SQL SELECT query'
101
101
 
@@ -105,7 +105,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_rename' do
105
105
  end
106
106
 
107
107
  context 'when the operand is ordered' do
108
- let(:operand) { base_relation.order }
108
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
109
109
 
110
110
  it_should_behave_like 'a generated SQL SELECT query'
111
111
 
@@ -114,7 +114,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_rename' do
114
114
  end
115
115
 
116
116
  context 'when the operand is reversed' do
117
- let(:operand) { base_relation.order.reverse }
117
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.reverse }
118
118
 
119
119
  it_should_behave_like 'a generated SQL SELECT query'
120
120
 
@@ -123,7 +123,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_rename' do
123
123
  end
124
124
 
125
125
  context 'when the operand is limited' do
126
- let(:operand) { base_relation.order.take(1) }
126
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.take(1) }
127
127
 
128
128
  it_should_behave_like 'a generated SQL SELECT query'
129
129
 
@@ -132,7 +132,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_rename' do
132
132
  end
133
133
 
134
134
  context 'when the operand is an offset' do
135
- let(:operand) { base_relation.order.drop(1) }
135
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1) }
136
136
 
137
137
  it_should_behave_like 'a generated SQL SELECT query'
138
138
 
@@ -12,7 +12,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
12
12
  let(:header) { [ id, name, age ] }
13
13
  let(:body) { [ [ 1, 'Dan Kubb', 35 ] ].each }
14
14
  let(:base_relation) { Relation::Base.new(relation_name, header, body) }
15
- let(:restriction) { operand.restrict { |r| r[:id].eq(1) } }
15
+ let(:restriction) { operand.restrict { |r| r.id.eq(1) } }
16
16
  let(:object) { described_class.new }
17
17
 
18
18
  context 'when the operand is a base relation' do
@@ -43,7 +43,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
43
43
  end
44
44
 
45
45
  context 'when the operand is a projection then a restriction' do
46
- let(:operand) { base_relation.project([ :id, :name ]).restrict { |r| r[:id].ne(2) } }
46
+ let(:operand) { base_relation.project([ :id, :name ]).restrict { |r| r.id.ne(2) } }
47
47
 
48
48
  it_should_behave_like 'a generated SQL SELECT query'
49
49
 
@@ -63,8 +63,8 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
63
63
 
64
64
  context 'when the operand is a rename' do
65
65
  context 'when the restriction includes the renamed column' do
66
- let(:operand) { base_relation.rename(:id => :user_id) }
67
- let(:restriction) { operand.restrict { |r| r[:user_id].eq(1) } }
66
+ let(:operand) { base_relation.rename(:id => :user_id) }
67
+ let(:restriction) { operand.restrict { |r| r.user_id.eq(1) } }
68
68
 
69
69
  it_should_behave_like 'a generated SQL SELECT query'
70
70
 
@@ -74,7 +74,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
74
74
 
75
75
  context 'when the restriction does not include the renamed column' do
76
76
  let(:operand) { base_relation.rename(:name => :other_name) }
77
- let(:restriction) { operand.restrict { |r| r[:id].eq(1) } }
77
+ let(:restriction) { operand.restrict { |r| r.id.eq(1) } }
78
78
 
79
79
  it_should_behave_like 'a generated SQL SELECT query'
80
80
 
@@ -84,7 +84,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
84
84
  end
85
85
 
86
86
  context 'when the operand is a restriction' do
87
- let(:operand) { base_relation.restrict { |r| r[:id].eq(1) } }
87
+ let(:operand) { base_relation.restrict { |r| r.id.eq(1) } }
88
88
 
89
89
  it_should_behave_like 'a generated SQL SELECT query'
90
90
 
@@ -94,9 +94,9 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
94
94
 
95
95
  context 'when the operand is a summarization' do
96
96
  context 'summarize per table dee' do
97
- let(:summarize_per) { TABLE_DEE }
98
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
99
- let(:restriction) { operand.restrict { |r| r[:count].eq(1) } }
97
+ let(:summarize_per) { TABLE_DEE }
98
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
99
+ let(:restriction) { operand.restrict { |r| r.count.eq(1) } }
100
100
 
101
101
  it_should_behave_like 'a generated SQL SELECT query'
102
102
 
@@ -105,9 +105,9 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
105
105
  end
106
106
 
107
107
  context 'summarize per table dum' do
108
- let(:summarize_per) { TABLE_DUM }
109
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
110
- let(:restriction) { operand.restrict { |r| r[:count].eq(1) } }
108
+ let(:summarize_per) { TABLE_DUM }
109
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
110
+ let(:restriction) { operand.restrict { |r| r.count.eq(1) } }
111
111
 
112
112
  it_should_behave_like 'a generated SQL SELECT query'
113
113
 
@@ -116,7 +116,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
116
116
  end
117
117
 
118
118
  context 'summarize by a subset of the operand header' do
119
- let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r[:age].count) } }
119
+ let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) } }
120
120
 
121
121
  it_should_behave_like 'a generated SQL SELECT query'
122
122
 
@@ -126,7 +126,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
126
126
  end
127
127
 
128
128
  context 'when the operand is ordered' do
129
- let(:operand) { base_relation.order }
129
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
130
130
 
131
131
  it_should_behave_like 'a generated SQL SELECT query'
132
132
 
@@ -135,7 +135,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
135
135
  end
136
136
 
137
137
  context 'when the operand is reversed' do
138
- let(:operand) { base_relation.order.reverse }
138
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.reverse }
139
139
 
140
140
  it_should_behave_like 'a generated SQL SELECT query'
141
141
 
@@ -144,7 +144,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
144
144
  end
145
145
 
146
146
  context 'when the operand is limited' do
147
- let(:operand) { base_relation.order.take(1) }
147
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.take(1) }
148
148
 
149
149
  it_should_behave_like 'a generated SQL SELECT query'
150
150
 
@@ -153,7 +153,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_algebra_restriction' d
153
153
  end
154
154
 
155
155
  context 'when the operand is an offset' do
156
- let(:operand) { base_relation.order.drop(1) }
156
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1) }
157
157
 
158
158
  it_should_behave_like 'a generated SQL SELECT query'
159
159