module Lycopene.Database.HDBC.Query where

import           Database.HDBC
import           Lycopene.Core (Lycopene(..), ProjectF(..))
import           Lycopene.Freer (foldFreer)
import           Lycopene.Database.DataSource (DataSource)
import           Lycopene.Database.Persist (Persist(..))
import           Lycopene.Database.HDBC.Project (persistProject)

-- Lift method
-- ----------------------------------------------------------------

-- | Lift 'relational-record' 'Insert' DSL into Persist monad
-- Integer means count of record inserted
--insertPersist :: (ToSql SqlValue p) => Insert p -> p -> Persist Integer
--insertPersist i p = Persist (\conn -> runInsert conn i p)

-- | Lift 'relational-record' 'InsertQuery' DSL into Persist monad
-- Integer means count of record inserted
-- insertQueryPersist :: (ToSql SqlValue p) => InsertQuery p -> p -> Persist Integer
-- insertQueryPersist i p = Persist (\conn -> runInsertQuery conn i p)

-- | Lift 'relational-record' 'Update' DSL into Persist monad
-- Integer means count of record updated
-- updatePersist :: (ToSql SqlValue p) => Update p -> p -> Persist Integer
-- updatePersist u p = Persist (\conn -> runUpdate conn u p)

-- | Lift 'relational-record' 'KeyUpdate' DSL into Persist monad
-- Integer means count of record updated
-- kupdatePersist :: (ToSql SqlValue a) => KeyUpdate p a -> a -> Persist Integer
-- kupdatePersist u k = Persist (\conn -> runKeyUpdate conn u k)

-- | Lift 'relational-record' 'Delete' DSL into Persist monad
-- Integer means count of record deleted
-- deletePersist :: (ToSql SqlValue p) => Delete p -> p -> Persist Integer
-- deletePersist d p = Persist (\conn -> runDelete conn d p)

-- | Lift 'relational-record' 'Relation' DSL into Persist monad.
-- Apply query parameter @p@ to 'Relation'
-- selectPersist :: (ToSql SqlValue p, FromSql SqlValue a) => Relation p a -> p -> Persist [a]
-- selectPersist q p = Persist (\conn -> runQuery conn (relationalQuery q) p)
