Sha256: 8b3a4df9c3f3270de8a55452f9f0a8291bbfdbeae8cc0d85d69ab56b67817326

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")

describe "filter_having extension" do
  before do
    deprecated do
      @ds = Sequel.mock[:t].extension(:filter_having)
    end
    @dsh = @ds.having(:a)
  end

  it "should make filter operate on HAVING clause if dataset has a HAVING clause" do
    @dsh.filter(:b).sql.must_equal 'SELECT * FROM t HAVING (a AND b)'
  end

  it "should make filter operate on WHERE clause if dataset does not have a HAVING clause" do
    @ds.filter(:b).sql.must_equal 'SELECT * FROM t WHERE b'
  end

  deprecated "should make and operate on HAVING clause if dataset has a HAVING clause" do
    @dsh.and(:b).sql.must_equal 'SELECT * FROM t HAVING (a AND b)'
  end

  deprecated "should make and operate on WHERE clause if dataset does not have a HAVING clause" do
    @ds.where(:a).and(:b).sql.must_equal 'SELECT * FROM t WHERE (a AND b)'
  end

  it "should make or operate on HAVING clause if dataset has a HAVING clause" do
    @dsh.or(:b).sql.must_equal 'SELECT * FROM t HAVING (a OR b)'
  end

  it "should make or operate on WHERE clause if dataset does not have a HAVING clause" do
    @ds.where(:a).or(:b).sql.must_equal 'SELECT * FROM t WHERE (a OR b)'
  end

  it "should make exclude operate on HAVING clause if dataset has a HAVING clause" do
    @dsh.exclude(:b).sql.must_equal 'SELECT * FROM t HAVING (a AND NOT b)'
  end

  it "should make exclude operate on WHERE clause if dataset does not have a HAVING clause" do
    @ds.exclude(:b).sql.must_equal 'SELECT * FROM t WHERE NOT b'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sequel-4.49.0 spec/extensions/filter_having_spec.rb
sequel-4.48.0 spec/extensions/filter_having_spec.rb