refactor: Change SET LOCAL gucs to set_config
This commit is contained in:
committed by
Steve Chavez
parent
9254f119f6
commit
7069bb3c01
@@ -16,8 +16,7 @@ module PostgREST.QueryBuilder (
|
||||
, readRequestToCountQuery
|
||||
, requestToCallProcQuery
|
||||
, limitedQuery
|
||||
, setLocalQuery
|
||||
, setLocalSearchPathQuery
|
||||
, setConfigLocal
|
||||
) where
|
||||
|
||||
import qualified Data.ByteString.Char8 as BS
|
||||
@@ -173,10 +172,7 @@ readRequestToCountQuery (Node (Select{from=qi, where_=logicForest}, _) _) =
|
||||
limitedQuery :: H.Snippet -> Maybe Integer -> H.Snippet
|
||||
limitedQuery query maxRows = query <> H.sql (maybe mempty (\x -> " LIMIT " <> BS.pack (show x)) maxRows)
|
||||
|
||||
setLocalQuery :: Text -> (Text, Text) -> SqlQuery
|
||||
setLocalQuery prefix (k, v) =
|
||||
"SET LOCAL " <> pgFmtIdent (prefix <> k) <> " = " <> pgFmtLit v <> ";"
|
||||
|
||||
setLocalSearchPathQuery :: [Text] -> SqlQuery
|
||||
setLocalSearchPathQuery vals =
|
||||
"SET LOCAL search_path = " <> BS.intercalate ", " (pgFmtLit <$> vals) <> ";"
|
||||
-- | Do a pg set_config(setting, value, true) call. This is equivalent to a SET LOCAL.
|
||||
setConfigLocal :: Text -> (Text, Text) -> Text
|
||||
setConfigLocal prefix (k, v) =
|
||||
"set_config(" <> decodeUtf8 (pgFmtLit (prefix <> k)) <> ", " <> decodeUtf8 (pgFmtLit v) <> ", true)"
|
||||
|
||||
Reference in New Issue
Block a user