Allow calling variadic functions with repeated query params or JSON array in body

This commit is contained in:
Wolfgang Walther
2020-10-26 17:49:51 -05:00
committed by Steve Chavez
parent 18cc214c04
commit 302d4e15ad
9 changed files with 128 additions and 23 deletions
+6 -4
View File
@@ -149,14 +149,16 @@ decodeProcs =
parseArgs = mapMaybe parseArg . filter (not . isPrefixOf "OUT" . toS) . map strip . split (==',')
parseArg :: Text -> Maybe PgArg
parseArg a =
let arg = lastDef "" $ splitOn "INOUT " a
(body, def) = breakOn " DEFAULT " arg
parseArg arg =
let isVariadic = isPrefixOf "VARIADIC " $ toS arg
-- argmode can be IN, OUT, INOUT, or VARIADIC
argNoMode = lastDef "" $ splitOn (if isVariadic then "VARIADIC " else "INOUT ") arg
(body, def) = breakOn " DEFAULT " argNoMode
(name, typ) = breakOn " " body in
if T.null typ
then Nothing
else Just $
PgArg (dropAround (== '"') name) (strip typ) (T.null def)
PgArg (dropAround (== '"') name) (strip typ) (T.null def) isVariadic
parseRetType :: Text -> Text -> Bool -> Char -> RetType
parseRetType schema name isSetOf typ