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
data/.travis.yml CHANGED
@@ -1,8 +1,10 @@
1
1
  bundler_args: --without guard metrics
2
2
  script: "bundle exec rake spec"
3
3
  rvm:
4
- - ree
5
4
  - 1.8.7
6
5
  - 1.9.2
7
- - ruby-head
8
6
  - rbx
7
+ # - rbx-2.0
8
+ - ree
9
+ - jruby
10
+ - ruby-head
data/Gemfile CHANGED
@@ -2,22 +2,21 @@
2
2
 
3
3
  source :rubygems
4
4
 
5
- gem 'veritas', '0.0.4', :git => 'git://github.com/dkubb/veritas.git'
5
+ gem 'veritas', '~> 0.0.5', :git => 'git://github.com/dkubb/veritas.git'
6
6
 
7
7
  group :development do
8
- gem 'backports', '~> 2.2.1'
9
- gem 'jeweler', '~> 1.6.0'
10
- gem 'rake', '~> 0.9.0'
8
+ gem 'backports', '~> 2.3.0'
9
+ gem 'jeweler', '~> 1.6.4'
10
+ gem 'rake', '~> 0.9.2'
11
11
  gem 'rspec', '~> 1.3.2'
12
- gem 'yard', '~> 0.7.1'
12
+ gem 'yard', '~> 0.7.2'
13
13
  end
14
14
 
15
15
  group :guard do
16
- gem 'growl', '~> 1.0.3'
17
- gem 'guard', '~> 0.3.4'
16
+ gem 'guard', '~> 0.5.1'
18
17
  gem 'guard-bundler', '~> 0.1.3'
19
18
  gem 'guard-ego', '~> 0.0.1'
20
- gem 'guard-rspec', '~> 0.3.1'
19
+ gem 'guard-rspec', '~> 0.4.0'
21
20
  end
22
21
 
23
22
  platform :jruby do
@@ -31,7 +30,7 @@ platforms :mri_18 do
31
30
  gem 'flay', '~> 1.4.2'
32
31
  gem 'flog', '~> 2.5.1'
33
32
  gem 'heckle', '~> 1.4.3'
34
- gem 'json', '~> 1.5.1'
33
+ gem 'json', '~> 1.5.3'
35
34
  gem 'metric_fu', '~> 2.1.1'
36
35
  gem 'mspec', '~> 1.5.17'
37
36
  gem 'rcov', '~> 0.9.9'
data/README.rdoc CHANGED
@@ -4,6 +4,23 @@ Relational algebra SQL generator
4
4
 
5
5
  http://travis-ci.org/dkubb/veritas-sql-generator.png
6
6
 
7
+ == Usage
8
+
9
+ # visit every node in the relation AST
10
+ generator = Veritas::SQL::Generator::Relation.visit(relation)
11
+
12
+ # generate an SQL string
13
+ sql = generator.to_sql
14
+
15
+ # generate an SQL subquery string
16
+ subquery_sql = generator.to_subquery
17
+
18
+ == Description
19
+
20
+ The purpose of this gem is to produce valid SQL from a veritas[https://github.com/dkubb/veritas] relation. A relation is a representation of a query constructed using relational algebra organized into an AST. Each node in the AST corresponds to an operation defined in the algebra.
21
+
22
+ The SQL produced has been verified and tested against PostgreSQL 9.0.4. Dialects for MySQL, SQLite3, Oracle and SQL Server are planned.
23
+
7
24
  == Note on Patches/Pull Requests
8
25
 
9
26
  * If you want your code merged into the mainline, please discuss
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake'
5
5
  require File.expand_path('../lib/veritas/sql/generator/version', __FILE__)
6
6
 
7
7
  begin
8
- gem('jeweler', '~> 1.6.0') if respond_to?(:gem, true)
8
+ gem('jeweler', '~> 1.6.2') if respond_to?(:gem, true)
9
9
  require 'jeweler'
10
10
 
11
11
  Jeweler::Tasks.new do |gem|
@@ -23,5 +23,5 @@ begin
23
23
 
24
24
  FileList['tasks/**/*.rake'].each { |task| import task }
25
25
  rescue LoadError
26
- puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler -v 1.6.0'
26
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler -v 1.6.2'
27
27
  end
data/TODO CHANGED
@@ -9,8 +9,6 @@
9
9
  * Create Veritas::Literal::Range::Inclusive
10
10
  * Create Veritas::Literal::Range::Exclusive
11
11
 
12
- * Adjust reek and roodi scores down to lower thresholds
13
-
14
12
  * Handle cases where an Inequality/Exclusion predicate is used (or a
15
13
  Negation wrapping an Equality/Inclusion) on an *optional* attribute.
16
14
  * Add "OR attribute IS NULL" to the statement to ensure cases when
@@ -3,7 +3,7 @@
3
3
  module Veritas
4
4
  module SQL
5
5
  module Generator
6
- VERSION = '0.0.4'
6
+ VERSION = '0.0.5'
7
7
  end # module Generator
8
8
  end # module SQL
9
9
  end # module Veritas
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'backports'
5
- require 'veritas/sql/generator'
5
+ require 'backports/basic_object'
6
+ require 'veritas-sql-generator'
6
7
  require 'spec'
7
8
  require 'spec/autorun'
8
9
 
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  describe SQL::Generator::Literal, '#visit_time' do
6
6
  subject { object.visit_time(time) }
7
7
 
8
- # Time#iso8601 is currently broken in JRuby 1.6.1 when fractional seconds are not 0
8
+ # Time#iso8601 is currently broken in JRuby 1.6.2 when fractional seconds are not 0
9
9
  def self.time_iso8601_broken?
10
- RUBY_PLATFORM =~ /java/ && JRUBY_VERSION <= '1.6.1' && RUBY_VERSION >= '1.9.2'
10
+ RUBY_PLATFORM.include?('java') && JRUBY_VERSION <= '1.6.2' && RUBY_VERSION >= '1.9.2'
11
11
  end
12
12
 
13
13
  let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Literal } }
@@ -55,7 +55,7 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_join' do
55
55
  end
56
56
 
57
57
  context 'when the operands are restrictions' do
58
- let(:operand) { base_relation.restrict { |r| r[:id].eq(1) } }
58
+ let(:operand) { base_relation.restrict { |r| r.id.eq(1) } }
59
59
 
60
60
  it_should_behave_like 'a generated SQL SELECT query'
61
61
 
@@ -65,8 +65,8 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_join' do
65
65
 
66
66
  context 'when the operand is a summarization' do
67
67
  context 'summarize per table dee' do
68
- let(:summarize_per) { TABLE_DEE }
69
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
68
+ let(:summarize_per) { TABLE_DEE }
69
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
70
70
 
71
71
  it_should_behave_like 'a generated SQL SELECT query'
72
72
 
@@ -75,8 +75,8 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_join' do
75
75
  end
76
76
 
77
77
  context 'summarize per table dum' do
78
- let(:summarize_per) { TABLE_DUM }
79
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
78
+ let(:summarize_per) { TABLE_DUM }
79
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
80
80
 
81
81
  it_should_behave_like 'a generated SQL SELECT query'
82
82
 
@@ -85,7 +85,7 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_join' do
85
85
  end
86
86
 
87
87
  context 'summarize by a subset of the operand header' do
88
- let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r[:age].count) } }
88
+ let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) } }
89
89
 
90
90
  it_should_behave_like 'a generated SQL SELECT query'
91
91
 
@@ -95,7 +95,7 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_join' do
95
95
  end
96
96
 
97
97
  context 'when the operands are ordered' do
98
- let(:operand) { base_relation.order }
98
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
99
99
 
100
100
  it_should_behave_like 'a generated SQL SELECT query'
101
101
 
@@ -104,7 +104,7 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_join' do
104
104
  end
105
105
 
106
106
  context 'when the operands are reversed' do
107
- let(:operand) { base_relation.order.reverse }
107
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.reverse }
108
108
 
109
109
  it_should_behave_like 'a generated SQL SELECT query'
110
110
 
@@ -113,7 +113,7 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_join' do
113
113
  end
114
114
 
115
115
  context 'when the operands are limited' do
116
- let(:operand) { base_relation.order.take(1) }
116
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.take(1) }
117
117
 
118
118
  it_should_behave_like 'a generated SQL SELECT query'
119
119
 
@@ -122,7 +122,7 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_join' do
122
122
  end
123
123
 
124
124
  context 'when the operands are offsets' do
125
- let(:operand) { base_relation.order.drop(1) }
125
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1) }
126
126
 
127
127
  it_should_behave_like 'a generated SQL SELECT query'
128
128
 
@@ -58,8 +58,8 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_product' do
58
58
  end
59
59
 
60
60
  context 'when the operand is a restriction' do
61
- let(:left) { users.restrict { |r| r[:id].eq(1) } }
62
- let(:right) { other.restrict { |r| r[:other_id].eq(1) } }
61
+ let(:left) { users.restrict { |r| r.id.eq(1) } }
62
+ let(:right) { other.restrict { |r| r.other_id.eq(1) } }
63
63
 
64
64
  it_should_behave_like 'a generated SQL SELECT query'
65
65
 
@@ -69,9 +69,9 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_product' do
69
69
 
70
70
  context 'when the operand is a summarization' do
71
71
  context 'summarize per table dee' do
72
- let(:summarize_per) { TABLE_DEE }
73
- let(:left) { users.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
74
- let(:right) { other.summarize(summarize_per) { |r| r.add(:other_count, r[:other_id].count) } }
72
+ let(:summarize_per) { TABLE_DEE }
73
+ let(:left) { users.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
74
+ let(:right) { other.summarize(summarize_per) { |r| r.add(:other_count, r.other_id.count) } }
75
75
 
76
76
  it_should_behave_like 'a generated SQL SELECT query'
77
77
 
@@ -80,9 +80,9 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_product' do
80
80
  end
81
81
 
82
82
  context 'summarize per table dum' do
83
- let(:summarize_per) { TABLE_DUM }
84
- let(:left) { users.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
85
- let(:right) { other.summarize(summarize_per) { |r| r.add(:other_count, r[:other_id].count) } }
83
+ let(:summarize_per) { TABLE_DUM }
84
+ let(:left) { users.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
85
+ let(:right) { other.summarize(summarize_per) { |r| r.add(:other_count, r.other_id.count) } }
86
86
 
87
87
  it_should_behave_like 'a generated SQL SELECT query'
88
88
 
@@ -91,8 +91,8 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_product' do
91
91
  end
92
92
 
93
93
  context 'summarize by a subset of the operand header' do
94
- let(:left) { users.summarize([ :id, :name ]) { |r| r.add(:count, r[:age].count) } }
95
- let(:right) { other.summarize([ :other_id, :other_name ]) { |r| r.add(:other_count, r[:other_age].count) } }
94
+ let(:left) { users.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) } }
95
+ let(:right) { other.summarize([ :other_id, :other_name ]) { |r| r.add(:other_count, r.other_age.count) } }
96
96
 
97
97
  it_should_behave_like 'a generated SQL SELECT query'
98
98
 
@@ -102,8 +102,8 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_product' do
102
102
  end
103
103
 
104
104
  context 'when the operand is ordered' do
105
- let(:left) { users.order }
106
- let(:right) { other.order }
105
+ let(:left) { users.sort_by { |r| [ r.id, r.name, r.age ] } }
106
+ let(:right) { other.sort_by { |r| [ r.other_id, r.other_name, r.other_age ] } }
107
107
 
108
108
  it_should_behave_like 'a generated SQL SELECT query'
109
109
 
@@ -112,8 +112,8 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_product' do
112
112
  end
113
113
 
114
114
  context 'when the operand is reversed' do
115
- let(:left) { users.order.reverse }
116
- let(:right) { other.order.reverse }
115
+ let(:left) { users.sort_by { |r| [ r.id, r.name, r.age ] }.reverse }
116
+ let(:right) { other.sort_by { |r| [ r.other_id, r.other_name, r.other_age ] }.reverse }
117
117
 
118
118
  it_should_behave_like 'a generated SQL SELECT query'
119
119
 
@@ -122,8 +122,8 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_product' do
122
122
  end
123
123
 
124
124
  context 'when the operand is limited' do
125
- let(:left) { users.order.take(1) }
126
- let(:right) { other.order.take(1) }
125
+ let(:left) { users.sort_by { |r| [ r.id, r.name, r.age ] }.take(1) }
126
+ let(:right) { other.sort_by { |r| [ r.other_id, r.other_name, r.other_age ] }.take(1) }
127
127
 
128
128
  it_should_behave_like 'a generated SQL SELECT query'
129
129
 
@@ -132,8 +132,8 @@ describe SQL::Generator::Relation::Binary, '#visit_veritas_algebra_product' do
132
132
  end
133
133
 
134
134
  context 'when the operand is an offset' do
135
- let(:left) { users.order.drop(1) }
136
- let(:right) { other.order.drop(1) }
135
+ let(:left) { users.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1) }
136
+ let(:right) { other.sort_by { |r| [ r.other_id, r.other_name, r.other_age ] }.drop(1) }
137
137
 
138
138
  it_should_behave_like 'a generated SQL SELECT query'
139
139
 
@@ -54,7 +54,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_difference' 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
 
@@ -67,8 +67,8 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_difference' do
67
67
 
68
68
  context 'when the operand is a summarization' do
69
69
  context 'summarize per table dee' do
70
- let(:summarize_per) { TABLE_DEE }
71
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
70
+ let(:summarize_per) { TABLE_DEE }
71
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
72
72
 
73
73
  it_should_behave_like 'a generated SQL SELECT query'
74
74
 
@@ -77,8 +77,8 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_difference' do
77
77
  end
78
78
 
79
79
  context 'summarize per table dum' do
80
- let(:summarize_per) { TABLE_DUM }
81
- let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r[:id].count) } }
80
+ let(:summarize_per) { TABLE_DUM }
81
+ let(:operand) { base_relation.summarize(summarize_per) { |r| r.add(:count, r.id.count) } }
82
82
 
83
83
  it_should_behave_like 'a generated SQL SELECT query'
84
84
 
@@ -87,7 +87,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_difference' do
87
87
  end
88
88
 
89
89
  context 'summarize by a subset of the operand header' do
90
- let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r[:age].count) } }
90
+ let(:operand) { base_relation.summarize([ :id, :name ]) { |r| r.add(:count, r.age.count) } }
91
91
 
92
92
  it_should_behave_like 'a generated SQL SELECT query'
93
93
 
@@ -97,7 +97,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_difference' do
97
97
  end
98
98
 
99
99
  context 'when the operand is ordered' do
100
- let(:operand) { base_relation.order }
100
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] } }
101
101
 
102
102
  it_should_behave_like 'a generated SQL SELECT query'
103
103
 
@@ -106,7 +106,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_difference' do
106
106
  end
107
107
 
108
108
  context 'when the operand is reversed' do
109
- let(:operand) { base_relation.order.reverse }
109
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.reverse }
110
110
 
111
111
  it_should_behave_like 'a generated SQL SELECT query'
112
112
 
@@ -115,7 +115,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_difference' do
115
115
  end
116
116
 
117
117
  context 'when the operand is limited' do
118
- let(:operand) { base_relation.order.take(1) }
118
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.take(1) }
119
119
 
120
120
  it_should_behave_like 'a generated SQL SELECT query'
121
121
 
@@ -124,7 +124,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_difference' do
124
124
  end
125
125
 
126
126
  context 'when the operands are offsets' do
127
- let(:operand) { base_relation.order.drop(1) }
127
+ let(:operand) { base_relation.sort_by { |r| [ r.id, r.name, r.age ] }.drop(1) }
128
128
 
129
129
  it_should_behave_like 'a generated SQL SELECT query'
130
130
 
@@ -54,7 +54,7 @@ describe SQL::Generator::Relation::Set, '#visit_veritas_algebra_intersection' 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_intersection' 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_intersection' 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_intersection' 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_intersection' 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_intersection' 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_intersection' 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_intersection' 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