Sha256: 2b583fd77760547c8ba0ecc13f0c69e2ffcea2b93a4797d3a8447c039657ede1

Contents?: true

Size: 1.49 KB

Versions: 32

Compression:

Stored size: 1.49 KB

Contents

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

describe "filter_having extension" do
  before do
    @ds = Sequel.mock[:t].extension(:filter_having)
    @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

  it "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

  it "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

32 entries across 30 versions & 2 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/sequel-4.47.0/spec/extensions/filter_having_spec.rb
tdiary-5.0.5 vendor/bundle/gems/sequel-4.44.0/spec/extensions/filter_having_spec.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/sequel-4.44.0/spec/extensions/filter_having_spec.rb
sequel-4.47.0 spec/extensions/filter_having_spec.rb
sequel-4.46.0 spec/extensions/filter_having_spec.rb
sequel-4.45.0 spec/extensions/filter_having_spec.rb
tdiary-5.0.4 vendor/bundle/gems/sequel-4.44.0/spec/extensions/filter_having_spec.rb
sequel-4.44.0 spec/extensions/filter_having_spec.rb
sequel-4.43.0 spec/extensions/filter_having_spec.rb
sequel-4.42.1 spec/extensions/filter_having_spec.rb
sequel-4.42.0 spec/extensions/filter_having_spec.rb
sequel-4.41.0 spec/extensions/filter_having_spec.rb
sequel-4.40.0 spec/extensions/filter_having_spec.rb
sequel-4.39.0 spec/extensions/filter_having_spec.rb
tdiary-5.0.2 vendor/bundle/gems/sequel-4.37.0/spec/extensions/filter_having_spec.rb
sequel-4.38.0 spec/extensions/filter_having_spec.rb
sequel-4.37.0 spec/extensions/filter_having_spec.rb
sequel-4.36.0 spec/extensions/filter_having_spec.rb
tdiary-5.0.1 vendor/bundle/gems/sequel-4.35.0/spec/extensions/filter_having_spec.rb
sequel-4.35.0 spec/extensions/filter_having_spec.rb