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.
- data/.travis.yml +4 -2
- data/Gemfile +8 -9
- data/README.rdoc +17 -0
- data/Rakefile +2 -2
- data/TODO +0 -2
- data/lib/veritas/sql/generator/version.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/unit/veritas/sql/generator/literal/visit_time_spec.rb +2 -2
- data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_join_spec.rb +10 -10
- data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_product_spec.rb +18 -18
- data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_difference_spec.rb +10 -10
- data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_intersection_spec.rb +10 -10
- data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_union_spec.rb +10 -10
- data/spec/unit/veritas/sql/generator/relation/unary/to_s_spec.rb +3 -3
- data/spec/unit/veritas/sql/generator/relation/unary/to_subquery_spec.rb +3 -3
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_extension_spec.rb +10 -10
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_projection_spec.rb +12 -12
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_rename_spec.rb +12 -12
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_restriction_spec.rb +17 -17
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_summarization_spec.rb +49 -49
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_limit_spec.rb +18 -18
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb +18 -18
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb +21 -14
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_reverse_spec.rb +18 -18
- data/tasks/metrics/heckle.rake +1 -0
- data/veritas-sql-generator.gemspec +17 -17
- metadata +33 -33
data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_off
|
|
16
16
|
let(:object) { described_class.new }
|
17
17
|
|
18
18
|
context 'when the operand is a base relation' do
|
19
|
-
let(:operand) { base_relation.
|
19
|
+
let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
|
20
20
|
|
21
21
|
it_should_behave_like 'a generated SQL SELECT query'
|
22
22
|
|
@@ -25,7 +25,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_off
|
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'when the operand is a projection' do
|
28
|
-
let(:operand) { base_relation.project([ :id, :name ]).
|
28
|
+
let(:operand) { base_relation.project([ :id, :name ]).sort_by { |r| [ r.id, r.name ] } }
|
29
29
|
|
30
30
|
it_should_behave_like 'a generated SQL SELECT query'
|
31
31
|
|
@@ -34,7 +34,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_off
|
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'when the operand is an extension' do
|
37
|
-
let(:operand) { base_relation.extend { |r| r.add(:one, 1) }.
|
37
|
+
let(:operand) { base_relation.extend { |r| r.add(:one, 1) }.sort_by { |r| [ r.id, r.name, r.age, r.one ] } }
|
38
38
|
|
39
39
|
it_should_behave_like 'a generated SQL SELECT query'
|
40
40
|
|
@@ -43,7 +43,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_off
|
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'when the operand is a rename' do
|
46
|
-
let(:operand) { base_relation.
|
46
|
+
let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.rename(:id => :user_id) }
|
47
47
|
|
48
48
|
it_should_behave_like 'a generated SQL SELECT query'
|
49
49
|
|
@@ -52,7 +52,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_off
|
|
52
52
|
end
|
53
53
|
|
54
54
|
context 'when the operand is a restriction' do
|
55
|
-
let(:operand) { base_relation.restrict { |r| r
|
55
|
+
let(:operand) { base_relation.restrict { |r| r.id.eq(1) }.sort_by { |r| [ r.id, r.name, r.age ] } }
|
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_relation_operation_off
|
|
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
|
65
|
+
let(:summarize_per) { TABLE_DEE }
|
66
|
+
let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) }.sort_by { |r| r.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_relation_operation_off
|
|
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
|
75
|
+
let(:summarize_per) { TABLE_DUM }
|
76
|
+
let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) }.sort_by { |r| r.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_relation_operation_off
|
|
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
|
85
|
+
let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) }.sort_by { |r| [ r.id, r.name, r.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_relation_operation_off
|
|
92
92
|
end
|
93
93
|
|
94
94
|
context 'when the operand is ordered' do
|
95
|
-
let(:operand) { base_relation.
|
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_relation_operation_off
|
|
101
101
|
end
|
102
102
|
|
103
103
|
context 'when the operand is reversed' do
|
104
|
-
let(:operand) { base_relation.
|
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_relation_operation_off
|
|
110
110
|
end
|
111
111
|
|
112
112
|
context 'when the operand is limited' do
|
113
|
-
let(:operand) { base_relation.
|
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_relation_operation_off
|
|
119
119
|
end
|
120
120
|
|
121
121
|
context 'when the operand is an offset' do
|
122
|
-
let(:operand) { base_relation.
|
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
|
|
@@ -128,7 +128,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_off
|
|
128
128
|
end
|
129
129
|
|
130
130
|
context 'when the operand is a difference' do
|
131
|
-
let(:operand) { base_relation.difference(base_relation).
|
131
|
+
let(:operand) { base_relation.difference(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
|
132
132
|
|
133
133
|
it_should_behave_like 'a generated SQL SELECT query'
|
134
134
|
|
@@ -137,7 +137,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_off
|
|
137
137
|
end
|
138
138
|
|
139
139
|
context 'when the operand is an intersection' do
|
140
|
-
let(:operand) { base_relation.intersect(base_relation).
|
140
|
+
let(:operand) { base_relation.intersect(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
|
141
141
|
|
142
142
|
it_should_behave_like 'a generated SQL SELECT query'
|
143
143
|
|
@@ -146,7 +146,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_off
|
|
146
146
|
end
|
147
147
|
|
148
148
|
context 'when the operand is a union' do
|
149
|
-
let(:operand) { base_relation.union(base_relation).
|
149
|
+
let(:operand) { base_relation.union(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
|
150
150
|
|
151
151
|
it_should_behave_like 'a generated SQL SELECT query'
|
152
152
|
|
@@ -155,7 +155,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_off
|
|
155
155
|
end
|
156
156
|
|
157
157
|
context 'when the operand is a join' do
|
158
|
-
let(:operand) { base_relation.join(base_relation).
|
158
|
+
let(:operand) { base_relation.join(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
|
159
159
|
|
160
160
|
it_should_behave_like 'a generated SQL SELECT query'
|
161
161
|
|
data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
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(:order) { operand.
|
15
|
+
let(:order) { operand.sort_by { |r| [ r.id, r.name, r.age ] } }
|
16
16
|
let(:object) { described_class.new }
|
17
17
|
|
18
18
|
context 'when the operand is a base relation' do
|
@@ -25,6 +25,8 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'when the operand is a projection' do
|
28
|
+
let(:order) { operand.sort_by { |r| [ r.id, r.name ] } }
|
29
|
+
|
28
30
|
context 'when the projection contains the base_relation' do
|
29
31
|
let(:operand) { base_relation.project([ :id, :name ]) }
|
30
32
|
|
@@ -35,7 +37,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
35
37
|
end
|
36
38
|
|
37
39
|
context 'when the projection contains an order' do
|
38
|
-
let(:operand) { base_relation.
|
40
|
+
let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.project([ :id, :name ]) }
|
39
41
|
|
40
42
|
it_should_behave_like 'a generated SQL SELECT query'
|
41
43
|
|
@@ -45,7 +47,8 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
45
47
|
end
|
46
48
|
|
47
49
|
context 'when the operand is an extension' do
|
48
|
-
let(:operand) { base_relation.extend { |r| r.add(:one, 1) }.
|
50
|
+
let(:operand) { base_relation.extend { |r| r.add(:one, 1) }.sort_by { |r| [ r.id, r.name, r.age, r.one ] } }
|
51
|
+
let(:order) { operand.sort_by { |r| [ r.id, r.name, r.age, r.one ] } }
|
49
52
|
|
50
53
|
it_should_behave_like 'a generated SQL SELECT query'
|
51
54
|
|
@@ -54,7 +57,8 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
54
57
|
end
|
55
58
|
|
56
59
|
context 'when the operand is a rename' do
|
57
|
-
let(:operand) { base_relation.rename(:id => :user_id)
|
60
|
+
let(:operand) { base_relation.rename(:id => :user_id) }
|
61
|
+
let(:order) { operand.sort_by { |r| [ r.user_id, r.name, r.age ] } }
|
58
62
|
|
59
63
|
it_should_behave_like 'a generated SQL SELECT query'
|
60
64
|
|
@@ -63,7 +67,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
63
67
|
end
|
64
68
|
|
65
69
|
context 'when the operand is a restriction' do
|
66
|
-
let(:operand) { base_relation.restrict { |r| r
|
70
|
+
let(:operand) { base_relation.restrict { |r| r.id.eq(1) } }
|
67
71
|
|
68
72
|
it_should_behave_like 'a generated SQL SELECT query'
|
69
73
|
|
@@ -72,9 +76,11 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
72
76
|
end
|
73
77
|
|
74
78
|
context 'when the operand is a summarization' do
|
79
|
+
let(:order) { operand.sort_by { |r| r.count } }
|
80
|
+
|
75
81
|
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
|
82
|
+
let(:summarize_per) { TABLE_DEE }
|
83
|
+
let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) }.sort_by { |r| r.count } }
|
78
84
|
|
79
85
|
it_should_behave_like 'a generated SQL SELECT query'
|
80
86
|
|
@@ -83,8 +89,8 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
83
89
|
end
|
84
90
|
|
85
91
|
context 'summarize per table dum' do
|
86
|
-
let(:summarize_per) { TABLE_DUM
|
87
|
-
let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r
|
92
|
+
let(:summarize_per) { TABLE_DUM }
|
93
|
+
let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) }.sort_by { |r| r.count } }
|
88
94
|
|
89
95
|
it_should_behave_like 'a generated SQL SELECT query'
|
90
96
|
|
@@ -93,7 +99,8 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
93
99
|
end
|
94
100
|
|
95
101
|
context 'summarize by a subset of the operand header' do
|
96
|
-
let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r
|
102
|
+
let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) }.sort_by { |r| [ r.id, r.name, r.count ] } }
|
103
|
+
let(:order) { operand.sort_by { |r| [ r.id, r.name, r.count ] } }
|
97
104
|
|
98
105
|
it_should_behave_like 'a generated SQL SELECT query'
|
99
106
|
|
@@ -103,7 +110,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
103
110
|
end
|
104
111
|
|
105
112
|
context 'when the operand is ordered' do
|
106
|
-
let(:operand) { base_relation.
|
113
|
+
let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
|
107
114
|
|
108
115
|
it_should_behave_like 'a generated SQL SELECT query'
|
109
116
|
|
@@ -112,7 +119,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
112
119
|
end
|
113
120
|
|
114
121
|
context 'when the operand is reversed' do
|
115
|
-
let(:operand) { base_relation.
|
122
|
+
let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.reverse }
|
116
123
|
|
117
124
|
it_should_behave_like 'a generated SQL SELECT query'
|
118
125
|
|
@@ -121,7 +128,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
121
128
|
end
|
122
129
|
|
123
130
|
context 'when the operand is limited' do
|
124
|
-
let(:operand) { base_relation.
|
131
|
+
let(:operand) { base_relation.sort_by{ [ id.desc, name.desc, age.desc ] }.take(1) }
|
125
132
|
|
126
133
|
it_should_behave_like 'a generated SQL SELECT query'
|
127
134
|
|
@@ -130,7 +137,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_ord
|
|
130
137
|
end
|
131
138
|
|
132
139
|
context 'when the operand is an offset' do
|
133
|
-
let(:operand) { base_relation.
|
140
|
+
let(:operand) { base_relation.sort_by{ [ id.desc, name.desc, age.desc ] }.drop(1) }
|
134
141
|
|
135
142
|
it_should_behave_like 'a generated SQL SELECT query'
|
136
143
|
|
data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_reverse_spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_rev
|
|
16
16
|
let(:object) { described_class.new }
|
17
17
|
|
18
18
|
context 'when the operand is a base relation' do
|
19
|
-
let(:operand) { base_relation.
|
19
|
+
let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
|
20
20
|
|
21
21
|
it_should_behave_like 'a generated SQL SELECT query'
|
22
22
|
|
@@ -25,7 +25,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_rev
|
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'when the operand is a projection' do
|
28
|
-
let(:operand) { base_relation.project([ :id, :name ]).
|
28
|
+
let(:operand) { base_relation.project([ :id, :name ]).sort_by { |r| [ r.id, r.name ] } }
|
29
29
|
|
30
30
|
it_should_behave_like 'a generated SQL SELECT query'
|
31
31
|
|
@@ -34,7 +34,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_rev
|
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'when the operand is an extension' do
|
37
|
-
let(:operand) { base_relation.extend { |r| r.add(:one, 1) }.
|
37
|
+
let(:operand) { base_relation.extend { |r| r.add(:one, 1) }.sort_by { |r| [ r.id, r.name, r.age, r.one ] } }
|
38
38
|
|
39
39
|
it_should_behave_like 'a generated SQL SELECT query'
|
40
40
|
|
@@ -43,7 +43,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_rev
|
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'when the operand is a rename' do
|
46
|
-
let(:operand) { base_relation.
|
46
|
+
let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.rename(:id => :user_id) }
|
47
47
|
|
48
48
|
it_should_behave_like 'a generated SQL SELECT query'
|
49
49
|
|
@@ -52,7 +52,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_rev
|
|
52
52
|
end
|
53
53
|
|
54
54
|
context 'when the operand is a restriction' do
|
55
|
-
let(:operand) { base_relation.restrict { |r| r
|
55
|
+
let(:operand) { base_relation.restrict { |r| r.id.eq(1) }.sort_by { |r| [ r.id, r.name, r.age ] } }
|
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_relation_operation_rev
|
|
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
|
65
|
+
let(:summarize_per) { TABLE_DEE }
|
66
|
+
let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) }.sort_by { |r| r.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_relation_operation_rev
|
|
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
|
75
|
+
let(:summarize_per) { TABLE_DUM }
|
76
|
+
let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) }.sort_by { |r| r.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_relation_operation_rev
|
|
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
|
85
|
+
let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) }.sort_by { |r| [ r.id, r.name, r.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_relation_operation_rev
|
|
92
92
|
end
|
93
93
|
|
94
94
|
context 'when the operand is ordered' do
|
95
|
-
let(:operand) { base_relation.
|
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_relation_operation_rev
|
|
101
101
|
end
|
102
102
|
|
103
103
|
context 'when the operand is reversed' do
|
104
|
-
let(:operand) { base_relation.
|
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_relation_operation_rev
|
|
110
110
|
end
|
111
111
|
|
112
112
|
context 'when the operand is limited' do
|
113
|
-
let(:operand) { base_relation.
|
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_relation_operation_rev
|
|
119
119
|
end
|
120
120
|
|
121
121
|
context 'when the operand is an offset' do
|
122
|
-
let(:operand) { base_relation.
|
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
|
|
@@ -128,7 +128,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_rev
|
|
128
128
|
end
|
129
129
|
|
130
130
|
context 'when the operand is a difference' do
|
131
|
-
let(:operand) { base_relation.difference(base_relation).
|
131
|
+
let(:operand) { base_relation.difference(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
|
132
132
|
|
133
133
|
it_should_behave_like 'a generated SQL SELECT query'
|
134
134
|
|
@@ -137,7 +137,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_rev
|
|
137
137
|
end
|
138
138
|
|
139
139
|
context 'when the operand is an intersection' do
|
140
|
-
let(:operand) { base_relation.intersect(base_relation).
|
140
|
+
let(:operand) { base_relation.intersect(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
|
141
141
|
|
142
142
|
it_should_behave_like 'a generated SQL SELECT query'
|
143
143
|
|
@@ -146,7 +146,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_rev
|
|
146
146
|
end
|
147
147
|
|
148
148
|
context 'when the operand is a union' do
|
149
|
-
let(:operand) { base_relation.union(base_relation).
|
149
|
+
let(:operand) { base_relation.union(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
|
150
150
|
|
151
151
|
it_should_behave_like 'a generated SQL SELECT query'
|
152
152
|
|
@@ -155,7 +155,7 @@ describe SQL::Generator::Relation::Unary, '#visit_veritas_relation_operation_rev
|
|
155
155
|
end
|
156
156
|
|
157
157
|
context 'when the operand is a join' do
|
158
|
-
let(:operand) { base_relation.join(base_relation).
|
158
|
+
let(:operand) { base_relation.join(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
|
159
159
|
|
160
160
|
it_should_behave_like 'a generated SQL SELECT query'
|
161
161
|
|
data/tasks/metrics/heckle.rake
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{veritas-sql-generator}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Dan Kubb}]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-07-29}
|
13
13
|
s.description = %q{Generate SQL from a veritas relation}
|
14
14
|
s.email = %q{dan.kubb@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -164,27 +164,27 @@ Gem::Specification.new do |s|
|
|
164
164
|
s.specification_version = 3
|
165
165
|
|
166
166
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
167
|
-
s.add_runtime_dependency(%q<veritas>, ["
|
168
|
-
s.add_development_dependency(%q<backports>, ["~> 2.
|
169
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.6.
|
170
|
-
s.add_development_dependency(%q<rake>, ["~> 0.9.
|
167
|
+
s.add_runtime_dependency(%q<veritas>, ["~> 0.0.5"])
|
168
|
+
s.add_development_dependency(%q<backports>, ["~> 2.3.0"])
|
169
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
170
|
+
s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
|
171
171
|
s.add_development_dependency(%q<rspec>, ["~> 1.3.2"])
|
172
|
-
s.add_development_dependency(%q<yard>, ["~> 0.7.
|
172
|
+
s.add_development_dependency(%q<yard>, ["~> 0.7.2"])
|
173
173
|
else
|
174
|
-
s.add_dependency(%q<veritas>, ["
|
175
|
-
s.add_dependency(%q<backports>, ["~> 2.
|
176
|
-
s.add_dependency(%q<jeweler>, ["~> 1.6.
|
177
|
-
s.add_dependency(%q<rake>, ["~> 0.9.
|
174
|
+
s.add_dependency(%q<veritas>, ["~> 0.0.5"])
|
175
|
+
s.add_dependency(%q<backports>, ["~> 2.3.0"])
|
176
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
177
|
+
s.add_dependency(%q<rake>, ["~> 0.9.2"])
|
178
178
|
s.add_dependency(%q<rspec>, ["~> 1.3.2"])
|
179
|
-
s.add_dependency(%q<yard>, ["~> 0.7.
|
179
|
+
s.add_dependency(%q<yard>, ["~> 0.7.2"])
|
180
180
|
end
|
181
181
|
else
|
182
|
-
s.add_dependency(%q<veritas>, ["
|
183
|
-
s.add_dependency(%q<backports>, ["~> 2.
|
184
|
-
s.add_dependency(%q<jeweler>, ["~> 1.6.
|
185
|
-
s.add_dependency(%q<rake>, ["~> 0.9.
|
182
|
+
s.add_dependency(%q<veritas>, ["~> 0.0.5"])
|
183
|
+
s.add_dependency(%q<backports>, ["~> 2.3.0"])
|
184
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
185
|
+
s.add_dependency(%q<rake>, ["~> 0.9.2"])
|
186
186
|
s.add_dependency(%q<rspec>, ["~> 1.3.2"])
|
187
|
-
s.add_dependency(%q<yard>, ["~> 0.7.
|
187
|
+
s.add_dependency(%q<yard>, ["~> 0.7.2"])
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|