From 65e7744858db3f3bf199aa0f0a588a41c594f457 Mon Sep 17 00:00:00 2001 From: Diogo Biazus Date: Wed, 2 Dec 2015 17:12:37 -0500 Subject: [PATCH] Uses anti_id computed column to make test case clearer --- test/Feature/QuerySpec.hs | 2 +- test/fixtures/schema.sql | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/Feature/QuerySpec.hs b/test/Feature/QuerySpec.hs index f238af540..99ec84403 100644 --- a/test/Feature/QuerySpec.hs +++ b/test/Feature/QuerySpec.hs @@ -134,7 +134,7 @@ spec = [json| [{"id":1},{"id":2},{"id":3},{"id":4},{"id":5},{"id":6},{"id":7},{"id":8},{"id":9},{"id":10},{"id":11},{"id":12},{"id":13},{"id":14},{"id":15}] |] it "order by computed column" $ - get "/items?order=always_true.asc,id.asc" `shouldRespondWith` + get "/items?order=anti_id.desc" `shouldRespondWith` [json| [{"id":1},{"id":2},{"id":3},{"id":4},{"id":5},{"id":6},{"id":7},{"id":8},{"id":9},{"id":10},{"id":11},{"id":12},{"id":13},{"id":14},{"id":15}] |] it "matches filtering nested items" $ diff --git a/test/fixtures/schema.sql b/test/fixtures/schema.sql index 1d65862a6..c73d66a83 100755 --- a/test/fixtures/schema.sql +++ b/test/fixtures/schema.sql @@ -462,6 +462,11 @@ CREATE FUNCTION public.always_true(test.items) RETURNS boolean ALTER FUNCTION public.always_true(test.items) OWNER TO postgrest_test; +CREATE FUNCTION public.anti_id(test.items) RETURNS bigint +LANGUAGE sql STABLE +AS $$ SELECT $1.id * -1 $$; + +ALTER FUNCTION public.anti_id(test.items) OWNER TO postgrest_test; ALTER TABLE ONLY authors_only