Allow returning XML from single-column queries

This commit is contained in:
Franz-Josef Färber
2022-05-04 10:27:28 -05:00
committed by Steve Chavez
parent a2349d90c0
commit 5a3fbd7111
6 changed files with 24 additions and 2 deletions
+8
View File
@@ -1010,6 +1010,14 @@ spec actualPgVersion = do
, matchHeaders = ["Content-Type" <:> "text/plain; charset=utf-8"]
}
it "can get raw xml output with Accept: text/xml" $
request methodGet "/xmltest?select=xml" (acceptHdrs "text/xml") ""
`shouldRespondWith`
"<myxml>foo</myxml>bar<foobar><baz/></foobar>"
{ matchStatus = 200
, matchHeaders = ["Content-Type" <:> "text/xml; charset=utf-8"]
}
it "fails if a single column is not selected" $ do
request methodGet "/images?select=img,name&name=eq.A.png" (acceptHdrs "application/octet-stream") ""
`shouldRespondWith`
+1
View File
@@ -178,6 +178,7 @@ GRANT ALL ON TABLE
, limited_delete_items_wnonuniq_view
, limited_delete_items_cpk_view
, limited_update_items_cpk_view
, xmltest
TO postgrest_test_anonymous;
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
+10
View File
@@ -2583,3 +2583,13 @@ select $$
</body>
</html>$$::pg_catalog.xml;
$_$;
CREATE TABLE test.xmltest (
id integer primary key,
xml pg_catalog.xml NOT NULL
);
INSERT INTO test.xmltest VALUES
(1, '<myxml>foo</myxml>'),
(2, 'bar'),
(3, '<foobar><baz/></foobar>');