Permalink
Browse files

Fix table creation to work better with schemas

  • Loading branch information...
mightybyte committed Aug 31, 2012
1 parent 1b3e76f commit f005c6afab43bc928030ade2ec89b501cc5d938f
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/Snap/Snaplet/Auth/Backends/PostgresqlSimple.hs
@@ -101,11 +101,12 @@ createTableIfMissing PostgresAuthManager{..} = do
withResource pamConnPool $ \conn -> do
res <- P.query_ conn $ Query $ T.encodeUtf8 $
"select relname from pg_class where relname='"
- `T.append` tblName pamTable `T.append` "'"
+ `T.append` schemaless (tblName pamTable) `T.append` "'"
when (null (res :: [Only T.Text])) $
P.execute_ conn (Query $ T.encodeUtf8 q) >> return ()
return ()
where
+ schemaless = T.reverse . T.takeWhile (/='.') . T.reverse
q = T.concat
[ "CREATE TABLE "
, tblName pamTable

0 comments on commit f005c6a

Please sign in to comment.