Fix #399 insert records in tables with no SELECT privileges

This commit is contained in:
Ruslan Talpa
2015-12-16 10:16:14 +02:00
parent 4bc4a68051
commit 4544ce3255
8 changed files with 68 additions and 26 deletions
+9
View File
@@ -93,6 +93,15 @@ spec struct pool = beforeAll_ resetDb $ around (withApp cfgDefault struct pool)
simpleHeaders p `shouldSatisfy` matchHeader hLocation "/no_pk\\?a=eq.bar&b=eq.baz"
simpleStatus p `shouldBe` created201
it "can insert in tables with no select privileges" $ do
p <- request methodPost "/insertonly"
[("Prefer", "return=minimal")]
[json| { "v":"some value" } |]
liftIO $ do
simpleBody p `shouldBe` ""
simpleStatus p `shouldBe` created201
it "can post nulls" $ do
p <- request methodPost "/no_pk"
[("Prefer", "return=representation")]
+1
View File
@@ -28,6 +28,7 @@ spec struct pool = around (withApp cfgDefault struct pool) $ do
, {"schema":"test","name":"has_count_column","insertable":false}
, {"schema":"test","name":"has_fk","insertable":true}
, {"schema":"test","name":"insertable_view_with_join","insertable":true}
, {"schema":"test","name":"insertonly","insertable":true}
, {"schema":"test","name":"items","insertable":true}
, {"schema":"test","name":"json","insertable":true}
, {"schema":"test","name":"materialized_view","insertable":false}
+2
View File
@@ -34,6 +34,8 @@ GRANT ALL ON TABLE
, users_tasks
TO postgrest_test_anonymous;
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
GRANT USAGE ON SEQUENCE
auto_incrementing_pk_id_seq
, items_id_seq
+9
View File
@@ -500,6 +500,15 @@ CREATE TABLE nullable_integer (
);
--
-- Name: insertonly; Type: TABLE; Schema: test; Owner: -
--
CREATE TABLE insertonly (
v text NOT NULL
);
--
-- Name: projects; Type: TABLE; Schema: test; Owner: -
--