@@ -32,6 +32,7 @@ import PostgREST.MediaType (MTPlanAttrs (..),
3232 getMediaType )
3333import PostgREST.Query.SqlFragment
3434import PostgREST.SchemaCache.Identifiers (FieldName )
35+ import PostgREST.SchemaCache.Routine (Routine )
3536
3637import Protolude
3738
@@ -86,8 +87,8 @@ prepareWrite selectQuery mutateQuery isInsert mt rep pKeys =
8687 | rep /= Full = " ''"
8788 | getMediaType mt == MTTextCSV = asCsvF
8889 | getMediaType mt == MTGeoJSON = asGeoJsonF
89- | getMediaType mt == MTSingularJSON = asJsonSingleF False
90- | otherwise = asJsonF False False False
90+ | getMediaType mt == MTSingularJSON = asJsonSingleF Nothing
91+ | otherwise = asJsonF Nothing
9192
9293 selectF
9394 -- prevent using any of the column names in ?select= when no response is returned from the CTE
@@ -119,21 +120,21 @@ prepareRead selectQuery countQuery countTotal mt binaryField =
119120
120121 bodyF
121122 | getMediaType mt == MTTextCSV = asCsvF
122- | getMediaType mt == MTSingularJSON = asJsonSingleF False
123+ | getMediaType mt == MTSingularJSON = asJsonSingleF Nothing
123124 | getMediaType mt == MTGeoJSON = asGeoJsonF
124125 | isJust binaryField && getMediaType mt == MTTextXML = asXmlF $ fromJust binaryField
125126 | isJust binaryField = asBinaryF $ fromJust binaryField
126- | otherwise = asJsonF False False False
127+ | otherwise = asJsonF Nothing
127128
128129 decodeIt :: HD. Result ResultSet
129130 decodeIt = case mt of
130131 MTPlan {} -> planRow
131132 _ -> HD. singleRow $ standardRow True
132133
133- prepareCall :: Bool -> Bool -> Bool -> SQL. Snippet -> SQL. Snippet -> SQL. Snippet -> Bool ->
134+ prepareCall :: Routine -> SQL. Snippet -> SQL. Snippet -> SQL. Snippet -> Bool ->
134135 MediaType -> Maybe FieldName -> Bool ->
135136 SQL. Statement () ResultSet
136- prepareCall returnsScalar returnsSingleComposite returnsSetOfScalar callProcQuery selectQuery countQuery countTotal mt binaryField =
137+ prepareCall rout callProcQuery selectQuery countQuery countTotal mt binaryField =
137138 SQL. dynamicallyParameterized (mtSnippet mt snippet) decodeIt
138139 where
139140 snippet =
@@ -151,12 +152,12 @@ prepareCall returnsScalar returnsSingleComposite returnsSetOfScalar callProcQuer
151152 (countCTEF, countResultF) = countF countQuery countTotal
152153
153154 bodyF
154- | getMediaType mt == MTSingularJSON = asJsonSingleF returnsScalar
155+ | getMediaType mt == MTSingularJSON = asJsonSingleF $ Just rout
155156 | getMediaType mt == MTTextCSV = asCsvF
156157 | getMediaType mt == MTGeoJSON = asGeoJsonF
157158 | isJust binaryField && getMediaType mt == MTTextXML = asXmlF $ fromJust binaryField
158159 | isJust binaryField = asBinaryF $ fromJust binaryField
159- | otherwise = asJsonF returnsScalar returnsSetOfScalar returnsSingleComposite
160+ | otherwise = asJsonF $ Just rout
160161
161162 decodeIt :: HD. Result ResultSet
162163 decodeIt = case mt of
0 commit comments