blob: dd170a256f8e95197e28a1154da33c73e48be40e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
require 'spec_helper'
module Arel
describe Having do
before do
@relation = Table.new(:developers)
end
describe '#to_sql' do
describe 'when given a predicate' do
it "manufactures sql with where clause conditions" do
sql = @relation.group(@relation[:department]).having("MIN(salary) > 1000").to_sql
adapter_is :mysql do
sql.should be_like(%Q{
SELECT `developers`.`id`, `developers`.`name`, `developers`.`salary`, `developers`.`department`
FROM `developers`
GROUP BY `developers`.`department`
HAVING MIN(salary) > 1000
})
end
adapter_is_not :mysql do
sql.should be_like(%Q{
SELECT "developers"."id", "developers"."name", "developers"."salary", "developers"."department"
FROM "developers"
GROUP BY "developers"."department"
HAVING MIN(salary) > 1000
})
end
end
end
end
end
end
|