aboutsummaryrefslogtreecommitdiffstats
path: root/spec/visitors
diff options
context:
space:
mode:
authorRaimonds Simanovskis <raimonds.simanovskis@gmail.com>2010-09-29 13:10:17 +0300
committerRaimonds Simanovskis <raimonds.simanovskis@gmail.com>2010-09-29 13:10:17 +0300
commite619462165bfab5bee85f9761df7f48a6b8f30f0 (patch)
tree480a4ff4d22ff03462613ca27ddf78895b25bd54 /spec/visitors
parent538faf2ebc0e0e52a876f3be59c6219f620c780b (diff)
downloadrails-e619462165bfab5bee85f9761df7f48a6b8f30f0.tar.gz
rails-e619462165bfab5bee85f9761df7f48a6b8f30f0.tar.bz2
rails-e619462165bfab5bee85f9761df7f48a6b8f30f0.zip
use subquery for limit when DISTINCT is used (in Oracle)
Diffstat (limited to 'spec/visitors')
-rw-r--r--spec/visitors/oracle_spec.rb10
1 files changed, 10 insertions, 0 deletions
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