Sha256: 94cbf71bd6b8967a17d43bc1e485f326c265ebbcee8fbd39d7b57a39fb5a80e6

Contents?: true

Size: 1.33 KB

Versions: 19

Compression:

Stored size: 1.33 KB

Contents

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

describe "filter_having extension" do
  before do
    @dataset = Sequel.mock[:test].extension(:empty_array_consider_nulls)
  end

  it "should handle all types of IN/NOT IN queries with empty arrays" do
    @dataset.filter(:id => []).sql.must_equal "SELECT * FROM test WHERE (id != id)"
    @dataset.filter([:id1, :id2] => []).sql.must_equal "SELECT * FROM test WHERE ((id1 != id1) AND (id2 != id2))"
    @dataset.exclude(:id => []).sql.must_equal "SELECT * FROM test WHERE (id = id)"
    @dataset.exclude([:id1, :id2] => []).sql.must_equal "SELECT * FROM test WHERE ((id1 = id1) AND (id2 = id2))"
  end

  it "should handle IN/NOT IN queries with multiple columns and an empty dataset where the database doesn't support it" do
    @dataset.meta_def(:supports_multiple_column_in?){false}
    db = Sequel.mock
    d1 = db[:test].select(:id1, :id2).filter(:region=>'Asia').columns(:id1, :id2)
    @dataset.filter([:id1, :id2] => d1).sql.must_equal "SELECT * FROM test WHERE ((id1 != id1) AND (id2 != id2))"
    db.sqls.must_equal ["SELECT id1, id2 FROM test WHERE (region = 'Asia')"]
    @dataset.exclude([:id1, :id2] => d1).sql.must_equal "SELECT * FROM test WHERE ((id1 = id1) AND (id2 = id2))"
    db.sqls.must_equal ["SELECT id1, id2 FROM test WHERE (region = 'Asia')"]
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
sequel-4.41.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.40.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.39.0 spec/extensions/empty_array_consider_nulls_spec.rb
tdiary-5.0.2 vendor/bundle/gems/sequel-4.37.0/spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.38.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.37.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.36.0 spec/extensions/empty_array_consider_nulls_spec.rb
tdiary-5.0.1 vendor/bundle/gems/sequel-4.35.0/spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.35.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.34.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.33.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.32.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.31.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.30.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.29.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.28.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.27.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.26.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-4.25.0 spec/extensions/empty_array_consider_nulls_spec.rb