Predicates
Fabien edited this page Dec 4, 2018
·
2 revisions
- 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
- 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%'
- 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')
- 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')
- controller:
filter_by :bar, with: :eq
- request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=toto'
- SQL:
"foo"."bar" = 'toto'
- 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')
- 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')
- controller:
filter_by :bar, with: :gt
- request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=3'
- SQL:
"foo"."bar" > 3
- 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)
- 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)
- controller:
filter_by :bar, with: :gteq
- request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=5'
- SQL:
"foo"."bar" >= 5
- 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)
- 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)
- controller:
filter_by :bar, with: :ilike
- request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=toto'
- SQL:
"foo"."bar" ILIKE '%toto%'
- 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)
- 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))
- 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))
- controller:
filter_by :bar, with: :lt
- request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=2'
- SQL:
"foo"."bar" < 2
- 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)
- 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)
- controller:
filter_by :bar, with: :lteq
- request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=2'
- SQL:
"foo"."bar" <= 2
- 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)
- 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)
- controller:
filter_by :bar, with: :matches
- request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=toto'
- SQL:
"foo"."bar" ILIKE 'toto'
- 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')
- 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')
- 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)
- controller:
filter_by :bar, with: :not_eq
- request:
curl -X GET 'http://localhost:3000/foo?filter[bar]=2'
- SQL:
"foo"."bar" != 3
- 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)
- 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)
- 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)
- 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))
- 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))