diff --git a/Database/SQLite/Simple.hs b/Database/SQLite/Simple.hs index b7cce82..b455e49 100644 --- a/Database/SQLite/Simple.hs +++ b/Database/SQLite/Simple.hs @@ -67,6 +67,7 @@ module Database.SQLite.Simple ( , queryWith , queryWith_ , queryNamed + , queryNamedWith , lastInsertRowId , changes , totalChanges @@ -377,6 +378,18 @@ queryNamed :: (FromRow r) => Connection -> Query -> [NamedParam] -> IO [r] queryNamed conn templ params = withStatementNamedParams conn templ params $ \stmt -> doFoldToList fromRow stmt +-- | A version of 'query' where the query parameters (placeholders) +-- are named and take an explicit RowParser +-- +-- Example: +-- +-- @ +-- r \<- 'queryNamed' fromRow c \"SELECT * FROM posts WHERE id=:id AND date>=:date\" [\":id\" ':=' postId, \":date\" ':=' afterDate] +-- @ +queryNamedWith :: RowParser r -> Connection -> Query -> [NamedParam] -> IO [r] +queryNamedWith fromRow_ conn templ params = + withStatementNamedParams conn templ params $ \stmt -> doFoldToList fromRow_ stmt + -- | A version of 'execute' that does not perform query substitution. execute_ :: Connection -> Query -> IO () execute_ conn template =