aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-29 13:38:40 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-29 13:38:40 -0700
commit5ec2fac114b1c70fe7ac87f4767b6f1cbc1e78fc (patch)
tree8fd01c74ec25d602c769c75d44aa3f26a65eac31 /spec
parentcf1db3ce28e6c9fcf6fc724f5467e6b6b450f8bf (diff)
parente619462165bfab5bee85f9761df7f48a6b8f30f0 (diff)
downloadrails-5ec2fac114b1c70fe7ac87f4767b6f1cbc1e78fc.tar.gz
rails-5ec2fac114b1c70fe7ac87f4767b6f1cbc1e78fc.tar.bz2
rails-5ec2fac114b1c70fe7ac87f4767b6f1cbc1e78fc.zip
Merge branch 'master' of github.com:brynary/arel
* 'master' of github.com:brynary/arel: use subquery for limit when DISTINCT is used (in Oracle) added missing require 'spec_helper' in crud_spec.rb
Diffstat (limited to 'spec')
-rw-r--r--spec/crud_spec.rb2
-rw-r--r--spec/visitors/oracle_spec.rb10
2 files changed, 12 insertions, 0 deletions
diff --git a/spec/crud_spec.rb b/spec/crud_spec.rb
index 3485df6685..36b2a0b4e4 100644
--- a/spec/crud_spec.rb
+++ b/spec/crud_spec.rb
@@ -1,3 +1,5 @@
+require 'spec_helper'
+
module Arel
class FakeCrudder < SelectManager
class FakeEngine
diff --git a/spec/visitors/oracle_spec.rb b/spec/visitors/oracle_spec.rb
index cdf0e3427f..93ade3ef3c 100644
--- a/spec/visitors/oracle_spec.rb
+++ b/spec/visitors/oracle_spec.rb
@@ -71,6 +71,16 @@ module Arel
}
end
+ it 'creates a subquery when there is DISTINCT' do
+ stmt = Nodes::SelectStatement.new
+ stmt.cores.first.projections << Nodes::SqlLiteral.new('DISTINCT id')
+ stmt.limit = 10
+ sql = @visitor.accept stmt
+ sql.should be_like %{
+ SELECT * FROM (SELECT DISTINCT id) WHERE ROWNUM <= 10
+ }
+ end
+
it 'creates a different subquery when there is an offset' do
stmt = Nodes::SelectStatement.new
stmt.limit = 10