1
require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
3
describe "filter_having extension" do
5
@ds = Sequel.mock[:t].extension(:filter_having)
9
it "should make filter operate on HAVING clause if dataset has a HAVING clause" do
10
@dsh.filter(:b).sql.should == 'SELECT * FROM t HAVING (a AND b)'
13
it "should make filter operate on WHERE clause if dataset does not have a HAVING clause" do
14
@ds.filter(:b).sql.should == 'SELECT * FROM t WHERE b'
17
it "should make and operate on HAVING clause if dataset has a HAVING clause" do
18
@dsh.and(:b).sql.should == 'SELECT * FROM t HAVING (a AND b)'
21
it "should make and operate on WHERE clause if dataset does not have a HAVING clause" do
22
@ds.where(:a).and(:b).sql.should == 'SELECT * FROM t WHERE (a AND b)'
25
it "should make or operate on HAVING clause if dataset has a HAVING clause" do
26
@dsh.or(:b).sql.should == 'SELECT * FROM t HAVING (a OR b)'
29
it "should make or operate on WHERE clause if dataset does not have a HAVING clause" do
30
@ds.where(:a).or(:b).sql.should == 'SELECT * FROM t WHERE (a OR b)'
33
it "should make exclude operate on HAVING clause if dataset has a HAVING clause" do
34
@dsh.exclude(:b).sql.should == 'SELECT * FROM t HAVING (a AND NOT b)'
37
it "should make exclude operate on WHERE clause if dataset does not have a HAVING clause" do
38
@ds.exclude(:b).sql.should == 'SELECT * FROM t WHERE NOT b'