File: exclude_or_null_spec.rb

package info (click to toggle)
ruby-sequel 5.41.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,548 kB
  • sloc: ruby: 104,241; makefile: 3
file content (19 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require_relative "spec_helper"

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

  it "#exclude_or_null should add WHERE condition where a is false or NULL" do
    @ds.exclude_or_null(:a).sql.must_equal "SELECT * FROM t WHERE NOT coalesce(a, 'f')"
  end

  it "#exclude_or_null_having should add HAVING condition where a is false or NULL" do
    @ds.exclude_or_null_having(:a).sql.must_equal "SELECT * FROM t HAVING NOT coalesce(a, 'f')"
  end

  it "should not effect normal exclude" do
    @ds.exclude(:a).sql.must_equal "SELECT * FROM t WHERE NOT a"
  end
end