mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2025-01-07 05:36:30 +03:00
Add typed delete running sequence.
--HG-- rename : relational-query-HDBC/src/Database/HDBC/Record/Insert.hs => relational-query-HDBC/src/Database/HDBC/Record/Delete.hs
This commit is contained in:
parent
d73324bbd1
commit
77ed3f9344
@ -27,6 +27,7 @@ library
|
||||
Database.HDBC.Record.Statement
|
||||
Database.HDBC.Record.Query
|
||||
Database.HDBC.Record.Insert
|
||||
Database.HDBC.Record.Delete
|
||||
Database.HDBC.Query.TH
|
||||
Database.HDBC.SqlValueExtra
|
||||
Database.HDBC.Schema.Driver
|
||||
|
74
relational-query-HDBC/src/Database/HDBC/Record/Delete.hs
Normal file
74
relational-query-HDBC/src/Database/HDBC/Record/Delete.hs
Normal file
@ -0,0 +1,74 @@
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
|
||||
-- |
|
||||
-- Module : Database.HDBC.Record.Delete
|
||||
-- Copyright : 2013 Kei Hibino
|
||||
-- License : BSD3
|
||||
--
|
||||
-- Maintainer : ex8k.hibino@gmail.com
|
||||
-- Stability : experimental
|
||||
-- Portability : unknown
|
||||
--
|
||||
-- This module provides typed 'Delete' running sequence
|
||||
-- which intermediate structres are typed.
|
||||
module Database.HDBC.Record.Delete (
|
||||
PreparedDelete, prepare, prepareDelete,
|
||||
BoundDelete, ExecutedDelete, executeDelete,
|
||||
|
||||
runPreparedDelete, runDelete
|
||||
) where
|
||||
|
||||
import Database.HDBC (IConnection, SqlValue)
|
||||
|
||||
import Database.Relational.Query (Delete, untypeDelete)
|
||||
import Database.Record (ToSql)
|
||||
|
||||
import Database.HDBC.Record.Statement
|
||||
(unsafePrepare, PreparedStatement,
|
||||
BoundStatement,
|
||||
executeNoFetch, ExecutedStatement,
|
||||
runPreparedNoFetch)
|
||||
|
||||
|
||||
-- | Typed prepared insert type.
|
||||
type PreparedDelete p = PreparedStatement p ()
|
||||
|
||||
-- | Typed prepared insert which has bound placeholder parameters.
|
||||
type BoundDelete = BoundStatement ()
|
||||
|
||||
-- | Typed executed insert.
|
||||
type ExecutedDelete = ExecutedStatement ()
|
||||
|
||||
-- | Typed prepare insert operation.
|
||||
prepare :: IConnection conn
|
||||
=> conn
|
||||
-> Delete p
|
||||
-> IO (PreparedDelete p)
|
||||
prepare conn = unsafePrepare conn . untypeDelete
|
||||
|
||||
-- | Same as 'prepare'.
|
||||
prepareDelete :: IConnection conn
|
||||
=> conn
|
||||
-> Delete p
|
||||
-> IO (PreparedDelete p)
|
||||
prepareDelete = prepare
|
||||
|
||||
-- | Typed execute insert operation.
|
||||
executeDelete :: BoundDelete -> IO Integer
|
||||
executeDelete = executeNoFetch
|
||||
|
||||
-- | Bind parameters, execute statement and get execution result.
|
||||
runPreparedDelete :: ToSql SqlValue p
|
||||
=> p
|
||||
-> PreparedDelete p
|
||||
-> IO Integer
|
||||
runPreparedDelete = runPreparedNoFetch
|
||||
|
||||
-- | Prepare insert statement, bind parameters,
|
||||
-- execute statement and get execution result.
|
||||
runDelete :: (IConnection conn, ToSql SqlValue p)
|
||||
=> conn
|
||||
-> p
|
||||
-> Delete p
|
||||
-> IO Integer
|
||||
runDelete conn p = (>>= runPreparedDelete p) . prepareDelete conn
|
Loading…
Reference in New Issue
Block a user