Skip to content

Predicates

Fabien edited this page Dec 4, 2018 · 2 revisions

Predicates

between

  • controller:
filter_by :bar, with: :between
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=3'
  • SQL:
"foo"."bar" BETWEEN 1 AND 3

does_not_match

  • controller:
filter_by :bar, with: :does_not_match
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=toto'
  • SQL:
"foo"."bar"  NOT ILIKE '%toto%'

does_not_match_all

  • controller:
filter_by :bar, with: :does_not_match_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=toto&filter[bar][]=tata]'
  • SQL:
("foo"."bar" NOT ILIKE 'toto' AND "foo"."bar" NOT ILIKE 'tata')

does_not_match_any

  • controller:
filter_by :bar, with: :does_not_match_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=toto&filter[bar][]=tata]'
  • SQL:
("foo"."bar" NOT ILIKE 'toto' OR "foo"."bar" NOT ILIKE 'tata')

eq

  • controller:
filter_by :bar, with: :eq
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=toto'
  • SQL:
"foo"."bar" = 'toto'

eq_all

  • controller:
filter_by :bar, with: :eq_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=toto&filter[bar][]=tata]'
  • SQL:
("foo"."bar" = 'toto' AND "foo"."bar" = 'tata')

eq_any

  • controller:
filter_by :bar, with: :eq_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=toto&filter[bar][]=tata]'
  • SQL:
("foo"."bar" = 'toto' OR "foo"."bar" = 'tata')

gt

  • controller:
filter_by :bar, with: :gt
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=3'
  • SQL:
"foo"."bar" > 3

gt_all

  • controller:
filter_by :bar, with: :gt_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=2&filter[bar][]=4'
  • SQL:
("foo"."bar" > 2 AND "foo"."bar" > 4)

gt_any

  • controller:
filter_by :bar, with: :gt_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=2&filter[bar][]=4'
  • SQL:
("foo"."bar" > 2 OR "foo"."bar" > 4)

gteq

  • controller:
filter_by :bar, with: :gteq
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=5'
  • SQL:
"foo"."bar" >= 5

gteq_all

  • controller:
filter_by :bar, with: :gteq_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=2&filter[bar][]=4'
  • SQL:
("foo"."bar" >= 2 AND "foo"."bar" >= 4)

gteq_any

  • controller:
filter_by :bar, with: :gteq_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=2&filter[bar][]=4'
  • SQL:
("foo"."bar" >= 2 OR "foo"."bar" >= 4)

ilike

  • controller:
filter_by :bar, with: :ilike
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=toto'
  • SQL:
"foo"."bar" ILIKE '%toto%'

in

  • controller:
filter_by :bar, with: :in
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=2'
  • SQL:
"foo"."bar" IN (1, 2)

in_all

  • controller:
filter_by :bar, with: :in_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1,2&filter[bar][]=3,4'
  • SQL:
("foo"."bar" IN (1, 2) AND "foo"."bar" IN (3, 4))

in_any

  • controller:
filter_by :bar, with: :in_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1,2&filter[bar][]=3,4'
  • SQL:
("foo"."bar" IN (1, 2) OR "foo"."bar" IN (3, 4))

lt

  • controller:
filter_by :bar, with: :lt
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=2'
  • SQL:
"foo"."bar" < 2

lt_all

  • controller:
filter_by :bar, with: :lt_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=2'
  • SQL:
("foo"."bar" < 1 AND "foo"."bar" < 2)

lt_any

  • controller:
filter_by :bar, with: :lt_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=2'
  • SQL:
("foo"."bar" < 1 OR "foo"."bar" < 2)

lteq

  • controller:
filter_by :bar, with: :lteq
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=2'
  • SQL:
"foo"."bar" <= 2

lteq_all

  • controller:
filter_by :bar, with: :lteq_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=2'
  • SQL:
("foo"."bar" <= 1 AND "foo"."bar" <= 2)

lteq_any

  • controller:
filter_by :bar, with: :lteq_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=2'
  • SQL:
("foo"."bar" <= 1 OR "foo"."bar" <= 2)

matches

  • controller:
filter_by :bar, with: :matches
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=toto'
  • SQL:
"foo"."bar" ILIKE 'toto'

matches_all

  • controller:
filter_by :bar, with: :matches_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=toto&filter[bar][]=tata]'
  • SQL:
("foo"."bar" ILIKE 'toto' AND "foo"."bar" ILIKE 'tata')

matches_any

  • controller:
filter_by :bar, with: :matches_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=toto&filter[bar][]=tata]'
  • SQL:
("foo"."bar" ILIKE 'toto' OR "foo"."bar" ILIKE 'tata')

not_between

  • controller:
filter_by :bar, with: :not_between
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=3'
  • SQL:
("foo"."bar" < 1 OR "foo"."bar" > 3)

not_eq

  • controller:
filter_by :bar, with: :not_eq
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=2'
  • SQL:
"foo"."bar" != 3

not_eq_all

  • controller:
filter_by :bar, with: :not_eq_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=3'
  • SQL:
("foo"."bar" != 1 AND "foo"."bar" != 3)

not_eq_any

  • controller:
filter_by :bar, with: :not_eq_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=3'
  • SQL:
("foo"."bar" != 1 OR "foo"."bar" != 3)

not_in

  • controller:
filter_by :bar, with: :not_in
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=3'
  • SQL:
"foo"."bar" NOT IN (1, 3)

not_in_all

  • controller:
filter_by :bar, with: :not_in_all
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=3'
  • SQL:
("foo"."bar" NOT IN (1) AND "foo"."bar" NOT IN (3))

not_in_any

  • controller:
filter_by :bar, with: :not_in_any
  • request:
curl -X GET 'http://localhost:3000/foo?filter[bar][]=1&filter[bar][]=3'
  • SQL:
("foo"."bar" NOT IN (1) OR "foo"."bar" NOT IN (3))