axiom-sql-generator 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/.ruby-gemset +1 -0
  4. data/.travis.yml +17 -23
  5. data/CONTRIBUTING.md +1 -2
  6. data/Gemfile +10 -3
  7. data/Gemfile.devtools +39 -27
  8. data/README.md +5 -33
  9. data/axiom-sql-generator.gemspec +3 -5
  10. data/config/devtools.yml +2 -0
  11. data/config/flay.yml +1 -1
  12. data/config/reek.yml +1 -1
  13. data/config/rubocop.yml +59 -0
  14. data/lib/axiom/sql/generator/core_ext/date_time.rb +5 -6
  15. data/lib/axiom/sql/generator/direction.rb +4 -4
  16. data/lib/axiom/sql/generator/function/predicate.rb +1 -1
  17. data/lib/axiom/sql/generator/relation.rb +12 -11
  18. data/lib/axiom/sql/generator/relation/binary.rb +1 -1
  19. data/lib/axiom/sql/generator/relation/insertion.rb +1 -1
  20. data/lib/axiom/sql/generator/relation/unary.rb +20 -20
  21. data/lib/axiom/sql/generator/version.rb +1 -1
  22. data/lib/axiom/sql/generator/visitor.rb +3 -3
  23. data/spec/spec_helper.rb +11 -10
  24. data/spec/support/config_alias.rb +2 -0
  25. data/spec/unit/axiom/sql/generator/direction/{visit_axiom_relation_operation_order_ascending_spec.rb → visit_axiom_relation_operation_sorted_ascending_spec.rb} +2 -2
  26. data/spec/unit/axiom/sql/generator/direction/{visit_axiom_relation_operation_order_descending_spec.rb → visit_axiom_relation_operation_sorted_descending_spec.rb} +2 -2
  27. data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_exclusion_spec.rb +1 -1
  28. data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_inclusion_spec.rb +1 -1
  29. data/spec/unit/axiom/sql/generator/function/predicate/visit_axiom_function_predicate_inequality_spec.rb +3 -3
  30. data/spec/unit/axiom/sql/generator/literal/visit_enumerable_spec.rb +1 -1
  31. data/spec/unit/axiom/sql/generator/relation/binary/base/to_subquery_spec.rb +7 -7
  32. data/spec/unit/axiom/sql/generator/relation/binary/base/visit_axiom_relation_base_spec.rb +8 -8
  33. data/spec/unit/axiom/sql/generator/relation/binary/to_s_spec.rb +7 -7
  34. data/spec/unit/axiom/sql/generator/relation/binary/to_subquery_spec.rb +7 -7
  35. data/spec/unit/axiom/sql/generator/relation/binary/visit_axiom_algebra_join_spec.rb +20 -20
  36. data/spec/unit/axiom/sql/generator/relation/binary/visit_axiom_algebra_product_spec.rb +26 -26
  37. data/spec/unit/axiom/sql/generator/relation/class_methods/visit_spec.rb +10 -10
  38. data/spec/unit/axiom/sql/generator/relation/insertion/to_subquery_spec.rb +2 -2
  39. data/spec/unit/axiom/sql/generator/relation/insertion/visit_axiom_relation_operation_insertion_spec.rb +23 -23
  40. data/spec/unit/axiom/sql/generator/relation/materialized/visit_axiom_relation_materialized_spec.rb +3 -3
  41. data/spec/unit/axiom/sql/generator/relation/materialized/visited_spec.rb +2 -2
  42. data/spec/unit/axiom/sql/generator/relation/set/class_methods/normalize_operand_headers_spec.rb +5 -5
  43. data/spec/unit/axiom/sql/generator/relation/set/to_s_spec.rb +7 -7
  44. data/spec/unit/axiom/sql/generator/relation/set/to_subquery_spec.rb +7 -7
  45. data/spec/unit/axiom/sql/generator/relation/set/visit_axiom_algebra_difference_spec.rb +19 -19
  46. data/spec/unit/axiom/sql/generator/relation/set/visit_axiom_algebra_intersection_spec.rb +19 -19
  47. data/spec/unit/axiom/sql/generator/relation/set/visit_axiom_algebra_union_spec.rb +19 -19
  48. data/spec/unit/axiom/sql/generator/relation/to_s_spec.rb +9 -9
  49. data/spec/unit/axiom/sql/generator/relation/to_sql_spec.rb +8 -8
  50. data/spec/unit/axiom/sql/generator/relation/to_subquery_spec.rb +9 -9
  51. data/spec/unit/axiom/sql/generator/relation/unary/to_s_spec.rb +9 -9
  52. data/spec/unit/axiom/sql/generator/relation/unary/to_subquery_spec.rb +11 -11
  53. data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_extension_spec.rb +17 -17
  54. data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_projection_spec.rb +23 -23
  55. data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_rename_spec.rb +19 -19
  56. data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_restriction_spec.rb +22 -22
  57. data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_algebra_summarization_spec.rb +48 -48
  58. data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_relation_base_spec.rb +8 -8
  59. data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_relation_operation_limit_spec.rb +24 -24
  60. data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_relation_operation_offset_spec.rb +24 -24
  61. data/spec/unit/axiom/sql/generator/relation/unary/visit_axiom_relation_operation_reverse_spec.rb +26 -26
  62. data/spec/unit/axiom/sql/generator/relation/unary/{visit_axiom_relation_operation_order_spec.rb → visit_axiom_relation_operation_sorted_spec.rb} +28 -28
  63. data/spec/unit/axiom/sql/generator/relation/visit_spec.rb +3 -3
  64. data/spec/unit/axiom/sql/generator/relation/visited_spec.rb +7 -7
  65. data/spec/unit/axiom/sql/generator/visitor/visit_spec.rb +2 -2
  66. metadata +22 -41
  67. data/.rvmrc +0 -1
@@ -5,14 +5,14 @@ require 'spec_helper'
5
5
  describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_base' do
6
6
  subject { object.visit_axiom_relation_base(base_relation) }
7
7
 
8
- let(:relation_name) { 'users' }
9
- let(:id) { Attribute::Integer.new(:id) }
10
- let(:name) { Attribute::String.new(:name) }
11
- let(:age) { Attribute::Integer.new(:age, :required => false) }
12
- let(:header) { [ id, name, age ] }
13
- let(:body) { [ [ 1, 'Dan Kubb', 35 ] ].each }
14
- let(:base_relation) { Relation::Base.new(relation_name, header, body) }
15
- let(:object) { described_class.new }
8
+ let(:relation_name) { 'users' }
9
+ let(:id) { Attribute::Integer.new(:id) }
10
+ let(:name) { Attribute::String.new(:name) }
11
+ let(:age) { Attribute::Integer.new(:age, required: false) }
12
+ let(:header) { [id, name, age] }
13
+ let(:body) { [[1, 'Dan Kubb', 35]].each }
14
+ let(:base_relation) { Relation::Base.new(relation_name, header, body) }
15
+ let(:object) { described_class.new }
16
16
 
17
17
  it_should_behave_like 'a generated SQL SELECT query'
18
18
 
@@ -5,18 +5,18 @@ require 'spec_helper'
5
5
  describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_limit' do
6
6
  subject { object.visit_axiom_relation_operation_limit(limit) }
7
7
 
8
- let(:relation_name) { 'users' }
9
- let(:id) { Attribute::Integer.new(:id) }
10
- let(:name) { Attribute::String.new(:name) }
11
- let(:age) { Attribute::Integer.new(:age, :required => false) }
12
- let(:header) { [ id, name, age ] }
13
- let(:body) { [ [ 1, 'Dan Kubb', 35 ] ].each }
14
- let(:base_relation) { Relation::Base.new(relation_name, header, body) }
15
- let(:limit) { operand.take(1) }
16
- let(:object) { described_class.new }
8
+ let(:relation_name) { 'users' }
9
+ let(:id) { Attribute::Integer.new(:id) }
10
+ let(:name) { Attribute::String.new(:name) }
11
+ let(:age) { Attribute::Integer.new(:age, required: false) }
12
+ let(:header) { [id, name, age] }
13
+ let(:body) { [[1, 'Dan Kubb', 35]].each }
14
+ let(:base_relation) { Relation::Base.new(relation_name, header, body) }
15
+ let(:limit) { operand.take(1) }
16
+ let(:object) { described_class.new }
17
17
 
18
18
  context 'when the operand is a base relation' do
19
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_limit
25
25
  end
26
26
 
27
27
  context 'when the operand is a projection' do
28
- let(:operand) { base_relation.project([ :id, :name ]).sort_by { |r| [ r.id, r.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_axiom_relation_operation_limit
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) }.sort_by { |r| [ r.id, r.name, r.age, r.one ] } }
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_axiom_relation_operation_limit
43
43
  end
44
44
 
45
45
  context 'when the operand is a rename' do
46
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.rename(:id => :user_id) }
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_axiom_relation_operation_limit
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) }.sort_by { |r| [ r.id, r.name, r.age ] } }
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
 
@@ -82,7 +82,7 @@ describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_limit
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) }.sort_by { |r| [ r.id, r.name, r.count ] } }
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
 
@@ -91,8 +91,8 @@ describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_limit
91
91
  end
92
92
  end
93
93
 
94
- context 'when the operand is ordered' do
95
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
94
+ context 'when the operand is sorted' do
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_axiom_relation_operation_limit
101
101
  end
102
102
 
103
103
  context 'when the operand is reversed' do
104
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.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_axiom_relation_operation_limit
110
110
  end
111
111
 
112
112
  context 'when the operand is limited' do
113
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.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_axiom_relation_operation_limit
119
119
  end
120
120
 
121
121
  context 'when the operand is an offset' do
122
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.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
 
@@ -128,7 +128,7 @@ describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_limit
128
128
  end
129
129
 
130
130
  context 'when the operand is a difference' do
131
- let(:operand) { base_relation.difference(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_limit
137
137
  end
138
138
 
139
139
  context 'when the operand is an intersection' do
140
- let(:operand) { base_relation.intersect(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_limit
146
146
  end
147
147
 
148
148
  context 'when the operand is a union' do
149
- let(:operand) { base_relation.union(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_limit
155
155
  end
156
156
 
157
157
  context 'when the operand is a join' do
158
- let(:operand) { base_relation.join(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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
 
@@ -5,18 +5,18 @@ require 'spec_helper'
5
5
  describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_offset' do
6
6
  subject { object.visit_axiom_relation_operation_offset(offset) }
7
7
 
8
- let(:relation_name) { 'users' }
9
- let(:id) { Attribute::Integer.new(:id) }
10
- let(:name) { Attribute::String.new(:name) }
11
- let(:age) { Attribute::Integer.new(:age, :required => false) }
12
- let(:header) { [ id, name, age ] }
13
- let(:body) { [ [ 1, 'Dan Kubb', 35 ] ].each }
14
- let(:base_relation) { Relation::Base.new(relation_name, header, body) }
15
- let(:offset) { operand.drop(1) }
16
- let(:object) { described_class.new }
8
+ let(:relation_name) { 'users' }
9
+ let(:id) { Attribute::Integer.new(:id) }
10
+ let(:name) { Attribute::String.new(:name) }
11
+ let(:age) { Attribute::Integer.new(:age, required: false) }
12
+ let(:header) { [id, name, age] }
13
+ let(:body) { [[1, 'Dan Kubb', 35]].each }
14
+ let(:base_relation) { Relation::Base.new(relation_name, header, body) }
15
+ let(:offset) { operand.drop(1) }
16
+ let(:object) { described_class.new }
17
17
 
18
18
  context 'when the operand is a base relation' do
19
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_offse
25
25
  end
26
26
 
27
27
  context 'when the operand is a projection' do
28
- let(:operand) { base_relation.project([ :id, :name ]).sort_by { |r| [ r.id, r.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_axiom_relation_operation_offse
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) }.sort_by { |r| [ r.id, r.name, r.age, r.one ] } }
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_axiom_relation_operation_offse
43
43
  end
44
44
 
45
45
  context 'when the operand is a rename' do
46
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.rename(:id => :user_id) }
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_axiom_relation_operation_offse
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) }.sort_by { |r| [ r.id, r.name, r.age ] } }
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
 
@@ -82,7 +82,7 @@ describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_offse
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) }.sort_by { |r| [ r.id, r.name, r.count ] } }
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
 
@@ -91,8 +91,8 @@ describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_offse
91
91
  end
92
92
  end
93
93
 
94
- context 'when the operand is ordered' do
95
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
94
+ context 'when the operand is sorted' do
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_axiom_relation_operation_offse
101
101
  end
102
102
 
103
103
  context 'when the operand is reversed' do
104
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.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_axiom_relation_operation_offse
110
110
  end
111
111
 
112
112
  context 'when the operand is limited' do
113
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.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_axiom_relation_operation_offse
119
119
  end
120
120
 
121
121
  context 'when the operand is an offset' do
122
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.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
 
@@ -128,7 +128,7 @@ describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_offse
128
128
  end
129
129
 
130
130
  context 'when the operand is a difference' do
131
- let(:operand) { base_relation.difference(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_offse
137
137
  end
138
138
 
139
139
  context 'when the operand is an intersection' do
140
- let(:operand) { base_relation.intersect(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_offse
146
146
  end
147
147
 
148
148
  context 'when the operand is a union' do
149
- let(:operand) { base_relation.union(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_offse
155
155
  end
156
156
 
157
157
  context 'when the operand is a join' do
158
- let(:operand) { base_relation.join(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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
 
@@ -3,20 +3,20 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_reverse' do
6
- subject { object.visit_axiom_relation_operation_reverse(order) }
7
-
8
- let(:relation_name) { 'users' }
9
- let(:id) { Attribute::Integer.new(:id) }
10
- let(:name) { Attribute::String.new(:name) }
11
- let(:age) { Attribute::Integer.new(:age, :required => false) }
12
- let(:header) { [ id, name, age ] }
13
- let(:body) { [ [ 1, 'Dan Kubb', 35 ] ].each }
14
- let(:base_relation) { Relation::Base.new(relation_name, header, body) }
15
- let(:order) { operand.reverse }
16
- let(:object) { described_class.new }
6
+ subject { object.visit_axiom_relation_operation_reverse(sorted) }
7
+
8
+ let(:relation_name) { 'users' }
9
+ let(:id) { Attribute::Integer.new(:id) }
10
+ let(:name) { Attribute::String.new(:name) }
11
+ let(:age) { Attribute::Integer.new(:age, required: false) }
12
+ let(:header) { [id, name, age] }
13
+ let(:body) { [[1, 'Dan Kubb', 35]].each }
14
+ let(:base_relation) { Relation::Base.new(relation_name, header, body) }
15
+ let(:sorted) { operand.reverse }
16
+ let(:object) { described_class.new }
17
17
 
18
18
  context 'when the operand is a base relation' do
19
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_rever
25
25
  end
26
26
 
27
27
  context 'when the operand is a projection' do
28
- let(:operand) { base_relation.project([ :id, :name ]).sort_by { |r| [ r.id, r.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_axiom_relation_operation_rever
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) }.sort_by { |r| [ r.id, r.name, r.age, r.one ] } }
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_axiom_relation_operation_rever
43
43
  end
44
44
 
45
45
  context 'when the operand is a rename' do
46
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.rename(:id => :user_id) }
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_axiom_relation_operation_rever
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) }.sort_by { |r| [ r.id, r.name, r.age ] } }
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
 
@@ -82,7 +82,7 @@ describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_rever
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) }.sort_by { |r| [ r.id, r.name, r.count ] } }
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
 
@@ -91,8 +91,8 @@ describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_rever
91
91
  end
92
92
  end
93
93
 
94
- context 'when the operand is ordered' do
95
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
94
+ context 'when the operand is sorted' do
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_axiom_relation_operation_rever
101
101
  end
102
102
 
103
103
  context 'when the operand is reversed' do
104
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.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_axiom_relation_operation_rever
110
110
  end
111
111
 
112
112
  context 'when the operand is limited' do
113
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.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_axiom_relation_operation_rever
119
119
  end
120
120
 
121
121
  context 'when the operand is an offset' do
122
- let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.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
 
@@ -128,7 +128,7 @@ describe SQL::Generator::Relation::Unary, '#visit_axiom_relation_operation_rever
128
128
  end
129
129
 
130
130
  context 'when the operand is a difference' do
131
- let(:operand) { base_relation.difference(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_rever
137
137
  end
138
138
 
139
139
  context 'when the operand is an intersection' do
140
- let(:operand) { base_relation.intersect(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_rever
146
146
  end
147
147
 
148
148
  context 'when the operand is a union' do
149
- let(:operand) { base_relation.union(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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_axiom_relation_operation_rever
155
155
  end
156
156
 
157
157
  context 'when the operand is a join' do
158
- let(:operand) { base_relation.join(base_relation).sort_by { |r| [ r.id, r.name, r.age ] } }
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