diff options
Diffstat (limited to 'spec/engines')
-rw-r--r-- | spec/engines/sql/unit/relations/take_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/engines/sql/unit/relations/take_spec.rb b/spec/engines/sql/unit/relations/take_spec.rb index cc3c3dbbf5..1e0d3e3cfe 100644 --- a/spec/engines/sql/unit/relations/take_spec.rb +++ b/spec/engines/sql/unit/relations/take_spec.rb @@ -52,6 +52,24 @@ module Arel }) end end + + it "manufactures count sql with limit" do + sql = Take.new(@relation.project(@relation[:id].count), @taken).to_sql + + adapter_is :mysql do + sql.should be_like(%Q{ + SELECT COUNT(`users`.`id`) AS count_id + FROM (SELECT 1 FROM `users` LIMIT 4) + }) + end + + adapter_is_not :mysql, :oracle do + sql.should be_like(%Q{ + SELECT COUNT("users"."id") AS count_id + FROM (SELECT 1 FROM "users" LIMIT 4) + }) + end + end end end end |