forked from rails/arel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding SqlLiteral with spec for counts
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..', 'spec_helper') | ||
|
||
module Arel | ||
describe SqlLiteral do | ||
before do | ||
@relation = Table.new(:users) | ||
end | ||
|
||
describe '#to_sql' do | ||
it "manufactures sql with a literal SQL fragment" do | ||
sql = @relation.project(Count.new(SqlLiteral.new("*"))).to_sql | ||
|
||
adapter_is :mysql do | ||
sql.should be_like(%Q{SELECT COUNT(*) AS count_id FROM `users`}) | ||
end | ||
|
||
adapter_is_not :mysql do | ||
sql.should be_like(%Q{SELECT COUNT(*) AS count_id FROM "users"}) | ||
end | ||
end | ||
end | ||
end | ||
end |