Sha256: 1be714ee7d7edcdfe1934899b1a6682de41406f33b733d0cf90f52fdd766822f

Contents?: true

Size: 1.3 KB

Versions: 45

Compression:

Stored size: 1.3 KB

Contents

require_relative "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
    db = Sequel.mock
    d1 = db[:test].select(:id1, :id2).filter(:region=>'Asia').columns(:id1, :id2)
    @dataset = @dataset.with_extend{def supports_multiple_column_in?; false end}
    @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

45 entries across 41 versions & 2 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/empty_array_consider_nulls_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/empty_array_consider_nulls_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/sequel-5.29.0/spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.29.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.28.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.27.0 spec/extensions/empty_array_consider_nulls_spec.rb
tdiary-5.1.0 vendor/bundle/gems/sequel-5.26.0/spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.26.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.25.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.24.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.23.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.22.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.21.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.20.0 spec/extensions/empty_array_consider_nulls_spec.rb
tdiary-5.0.13 vendor/bundle/gems/sequel-5.18.0/spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.19.0 spec/extensions/empty_array_consider_nulls_spec.rb
tdiary-5.0.12.1 vendor/bundle/gems/sequel-5.18.0/spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.18.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.17.0 spec/extensions/empty_array_consider_nulls_spec.rb
sequel-5.16.0 spec/extensions/empty_array_consider_nulls_spec.rb