diff options
author | Joris | 2020-01-05 16:03:48 +0100 |
---|---|---|
committer | Joris | 2020-01-05 16:03:48 +0100 |
commit | fff99e6fb1c03235e219a94ce52acf5a50d3fb62 (patch) | |
tree | 45f850ef5a2d8bbd36f2d98c8876ed2d53440188 /server/src/Persistence/User.hs | |
parent | cdb0ae1aeb22d7d7c36acb9d580f3723aa469829 (diff) |
Use named parameters instead of positional parameters in persistence queries
Diffstat (limited to 'server/src/Persistence/User.hs')
-rw-r--r-- | server/src/Persistence/User.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/server/src/Persistence/User.hs b/server/src/Persistence/User.hs index 3c3a2b1..89eb57d 100644 --- a/server/src/Persistence/User.hs +++ b/server/src/Persistence/User.hs @@ -5,7 +5,7 @@ module Persistence.User import qualified Data.Maybe as Maybe import Data.Text (Text) -import Database.SQLite.Simple (FromRow (fromRow), Only (Only)) +import Database.SQLite.Simple (FromRow (fromRow), NamedParam ((:=))) import qualified Database.SQLite.Simple as SQLite import Prelude hiding (id) @@ -30,8 +30,11 @@ list = ) get :: Text -> Query (Maybe User) -get userEmail = +get email = Query (\conn -> do fmap (\(Row u) -> u) . Maybe.listToMaybe <$> - SQLite.query conn "SELECT * FROM user WHERE email = ? LIMIT 1" (Only userEmail) + SQLite.queryNamed + conn + "SELECT * FROM user WHERE email = :email LIMIT 1" + [ ":email" := email ] ) |