From aae55e028261980f36c7a69ca9b9174fea36fef5 Mon Sep 17 00:00:00 2001 From: Diogo Biazus Date: Sat, 17 Oct 2015 20:41:42 -0400 Subject: [PATCH] Make complete match agains ClaimsMap in setVar --- src/PostgREST/Auth.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PostgREST/Auth.hs b/src/PostgREST/Auth.hs index 16949c2a2..3a5d75209 100644 --- a/src/PostgREST/Auth.hs +++ b/src/PostgREST/Auth.hs @@ -57,7 +57,12 @@ setDBEnv maybeClaims = (map setVar . toList) <$> maybeClaims where setVar ("role", String val) = setRole val - setVar (key, String val) = "set local postgrest.claims" <> key <> " = " <> cs (pgFmtLit val) <> ";" + setVar (key, String val) = "set local postgrest.claims" <> key <> " = " <> pgFmtLit val <> ";" + setVar (key, Bool val) = "set local postgrest.claims" <> key <> " = " <> showText val <> ";" + setVar (key, Number val) = "set local postgrest.claims" <> key <> " = " <> showText val <> ";" + setVar _ = "" + showText :: Show a => a -> Text + showText = cs . show setRole :: Text -> Text setRole role = "set local role " <> cs (pgFmtLit role) <> ";"