Sha256: cb33d237e225f7a181adead4f97a05478e58ebf422e1462a68261f31b9ef0fcd

Contents?: true

Size: 952 Bytes

Versions: 34

Compression:

Stored size: 952 Bytes

Contents

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

describe "split_array_nil extension" do
  before do
    @ds = Sequel.mock[:table].extension(:split_array_nil)
  end

  it "should split IN with nil in array into separate OR IS NULL clause" do
    @ds.filter(:a=>[1, nil]).sql.must_equal "SELECT * FROM table WHERE ((a IN (1)) OR (a IS NULL))"
  end

  it "should split NOT IN with nil in array into separate AND IS NOT NULL clause" do
    @ds.exclude(:a=>[1, nil]).sql.must_equal "SELECT * FROM table WHERE ((a NOT IN (1)) AND (a IS NOT NULL))"
  end

  it "should not affect other IN/NOT in clauses" do
    @ds.filter(:a=>[1, 2]).sql.must_equal "SELECT * FROM table WHERE (a IN (1, 2))"
    @ds.exclude(:a=>[1, 2]).sql.must_equal "SELECT * FROM table WHERE (a NOT IN (1, 2))"
  end

  it "should not affect other types of filters clauses" do
    @ds.filter(:a=>1).sql.must_equal "SELECT * FROM table WHERE (a = 1)"
  end
end

Version data entries

34 entries across 32 versions & 2 rubygems

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