Add test for embedding on a view with group by

This commit is contained in:
steve-chavez
2018-12-12 12:07:30 -05:00
committed by Steve Chávez
parent 501edc718d
commit d78410473e
3 changed files with 16 additions and 0 deletions
+8
View File
@@ -425,6 +425,14 @@ spec = do
{"tournament":"tournament_3","player_view":{"first_name":"first_name_3"}}] |]
{ matchHeaders = [matchContentTypeJson] }
it "can embed a view that has group by" $
get "/projects_count_grouped_by?select=number_of_projects,client(name)" `shouldRespondWith`
[json|
[{"number_of_projects":1,"client":null},
{"number_of_projects":2,"client":{"name":"Microsoft"}},
{"number_of_projects":2,"client":{"name":"Apple"}}] |]
{ matchHeaders = [matchContentTypeJson] }
describe "path fixed" $ do
it "works when requesting children 2 levels" $
get "/clients?id=eq.1&select=id,projects:projects.client_id(id,tasks(id))" `shouldRespondWith`
+1
View File
@@ -95,6 +95,7 @@ GRANT ALL ON TABLE
, contract_view
, ltree_sample
, isn_sample
, projects_count_grouped_by
TO postgrest_test_anonymous;
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
+7
View File
@@ -1553,6 +1553,13 @@ select
from odd_years_books x
join private.publishers y on y.id = x.first_publisher_id;
create view test.projects_count_grouped_by as
select
client_id,
count(id) as number_of_projects
from projects
group by client_id;
CREATE TABLE test."Foo"(
id int primary key,
name text