Allow returning XML from single-column queries
This commit is contained in:
committed by
Steve Chavez
parent
a2349d90c0
commit
5a3fbd7111
@@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- #2236, Support POSIX regular expression operators for row filtering - @enote-kane
|
- #2236, Support POSIX regular expression operators for row filtering - @enote-kane
|
||||||
- #2202, Allow returning XML from RPCs - @fjf2002
|
- #2202, Allow returning XML from RPCs - @fjf2002
|
||||||
- #2269, Allow `limit=0` in the request query to return an empty array - @gautam1168, @laurenceisla
|
- #2269, Allow `limit=0` in the request query to return an empty array - @gautam1168, @laurenceisla
|
||||||
|
- #2268, Allow returning XML from single-column queries #2268 - @fjf2002
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ handleRead headersOnly identifier context@RequestContext{..} = do
|
|||||||
(iAcceptContentType == CTSingularJSON)
|
(iAcceptContentType == CTSingularJSON)
|
||||||
(shouldCount iPreferCount)
|
(shouldCount iPreferCount)
|
||||||
(iAcceptContentType == CTTextCSV)
|
(iAcceptContentType == CTTextCSV)
|
||||||
|
(iAcceptContentType == CTTextXML)
|
||||||
bField
|
bField
|
||||||
configDbPreparedStatements
|
configDbPreparedStatements
|
||||||
|
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ createWriteStatement selectQuery mutateQuery wantSingle isInsert asCsv rep pKeys
|
|||||||
decodeStandard =
|
decodeStandard =
|
||||||
fromMaybe (Nothing, 0, [], mempty, Right [], Right Nothing) <$> HD.rowMaybe standardRow
|
fromMaybe (Nothing, 0, [], mempty, Right [], Right Nothing) <$> HD.rowMaybe standardRow
|
||||||
|
|
||||||
createReadStatement :: SQL.Snippet -> SQL.Snippet -> Bool -> Bool -> Bool -> Maybe FieldName -> Bool ->
|
createReadStatement :: SQL.Snippet -> SQL.Snippet -> Bool -> Bool -> Bool -> Bool -> Maybe FieldName -> Bool ->
|
||||||
SQL.Statement () ResultsWithCount
|
SQL.Statement () ResultsWithCount
|
||||||
createReadStatement selectQuery countQuery isSingle countTotal asCsv binaryField =
|
createReadStatement selectQuery countQuery isSingle countTotal asCsv asXml binaryField =
|
||||||
SQL.dynamicallyParameterized snippet decodeStandard
|
SQL.dynamicallyParameterized snippet decodeStandard
|
||||||
where
|
where
|
||||||
snippet =
|
snippet =
|
||||||
@@ -109,6 +109,7 @@ createReadStatement selectQuery countQuery isSingle countTotal asCsv binaryField
|
|||||||
bodyF
|
bodyF
|
||||||
| asCsv = asCsvF
|
| asCsv = asCsvF
|
||||||
| isSingle = asJsonSingleF False
|
| isSingle = asJsonSingleF False
|
||||||
|
| isJust binaryField && asXml = asXmlF $ fromJust binaryField
|
||||||
| isJust binaryField = asBinaryF $ fromJust binaryField
|
| isJust binaryField = asBinaryF $ fromJust binaryField
|
||||||
| otherwise = asJsonF False
|
| otherwise = asJsonF False
|
||||||
|
|
||||||
|
|||||||
@@ -1010,6 +1010,14 @@ spec actualPgVersion = do
|
|||||||
, matchHeaders = ["Content-Type" <:> "text/plain; charset=utf-8"]
|
, 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
|
it "fails if a single column is not selected" $ do
|
||||||
request methodGet "/images?select=img,name&name=eq.A.png" (acceptHdrs "application/octet-stream") ""
|
request methodGet "/images?select=img,name&name=eq.A.png" (acceptHdrs "application/octet-stream") ""
|
||||||
`shouldRespondWith`
|
`shouldRespondWith`
|
||||||
|
|||||||
Vendored
+1
@@ -178,6 +178,7 @@ GRANT ALL ON TABLE
|
|||||||
, limited_delete_items_wnonuniq_view
|
, limited_delete_items_wnonuniq_view
|
||||||
, limited_delete_items_cpk_view
|
, limited_delete_items_cpk_view
|
||||||
, limited_update_items_cpk_view
|
, limited_update_items_cpk_view
|
||||||
|
, xmltest
|
||||||
TO postgrest_test_anonymous;
|
TO postgrest_test_anonymous;
|
||||||
|
|
||||||
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
|
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
|
||||||
|
|||||||
Vendored
+10
@@ -2583,3 +2583,13 @@ select $$
|
|||||||
</body>
|
</body>
|
||||||
</html>$$::pg_catalog.xml;
|
</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>');
|
||||||
|
|||||||
Reference in New Issue
Block a user