fix: Allow schema names with special characters in the search path

Fixes regression where the search path did not recognize schemas with uppercase, spaces and other special characters in their names.
This commit is contained in:
Laurence Isla
2022-06-23 18:54:43 -05:00
committed by GitHub
parent 870f7a39b0
commit f7745e1569
11 changed files with 60 additions and 13 deletions
+9
View File
@@ -24,6 +24,7 @@ module PostgREST.Query.SqlFragment
, orderF
, pgFmtColumn
, pgFmtIdent
, pgFmtIdentList
, pgFmtJoinCondition
, pgFmtLogicTree
, pgFmtOrderTerm
@@ -156,6 +157,14 @@ pgFmtIdent x = encodeUtf8 $ "\"" <> T.replace "\"" "\"\"" (trimNullChars x) <> "
trimNullChars :: Text -> Text
trimNullChars = T.takeWhile (/= '\x0')
-- |
-- Format a list of identifiers and separate them by commas.
--
-- >>> pgFmtIdentList ["schema_1", "schema_2", "SPECIAL \"@/\\#~_-"]
-- "\"schema_1\", \"schema_2\", \"SPECIAL \"\"@/\\#~_-\""
pgFmtIdentList :: [Text] -> SqlFragment
pgFmtIdentList schemas = BS.intercalate ", " $ pgFmtIdent <$> schemas
asCsvF :: SqlFragment
asCsvF = asCsvHeaderF <> " || '\n' || " <> asCsvBodyF
where