Skip to content

Commit

Permalink
Added failing test for #1480
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Jun 28, 2022
1 parent dbb4ec6 commit 1f42187
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Test/IDE/CodeGeneration/MigrationGenerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,26 @@ CREATE OR REPLACE FUNCTION a() RETURNS TRIGGER AS $$BEGIN
END;$$ language PLPGSQL;|]

diffSchemas targetSchema actualSchema `shouldBe` migration

it "should not detect changes in complex policies" do
-- https://github.com/digitallyinduced/ihp/issues/1480
let targetSchema = sql $ cs [plain|
CREATE POLICY "Users can manage servers they have access to" ON servers USING (user_id = ihp_user_id() OR (EXISTS (SELECT 1 FROM public.user_server_access WHERE user_server_access.user_id = user_id AND user_server_access.server_id = servers.id))) WITH CHECK (user_id = ihp_user_id());
|]
let actualSchema = sql $ cs [plain|
--
-- Name: servers Users can manage servers they have access to; Type: POLICY; Schema: public; Owner: -
--

CREATE POLICY "Users can manage servers they have access to" ON public.servers USING (((user_id = public.ihp_user_id()) OR (EXISTS ( SELECT 1
FROM public.user_server_access
WHERE ((user_server_access.user_id = user_server_access.user_id) AND (user_server_access.server_id = servers.id)))))) WITH CHECK ((user_id = public.ihp_user_id()));

|]
let migration = sql [i|
|]

diffSchemas targetSchema actualSchema `shouldBe` migration


sql :: Text -> [Statement]
Expand Down

0 comments on commit 1f42187

Please sign in to comment.