relational-query: prepare to rename derived* names to short names.

This commit is contained in:
Kei Hibino 2018-06-11 18:34:59 +09:00
parent 967de7cab0
commit 7070c1005b

View File

@ -17,27 +17,38 @@ module Database.Relational.Type (
relationalQuerySQL, relationalQuerySQL,
-- * Typed update statement -- * Typed update statement
KeyUpdate (..), unsafeTypedKeyUpdate, typedKeyUpdate, typedKeyUpdateTable, derivedKeyUpdate, KeyUpdate (..), unsafeTypedKeyUpdate, typedKeyUpdate, typedKeyUpdateTable, keyUpdate,
Update (..), unsafeTypedUpdate, typedUpdate', typedUpdate, derivedUpdate', derivedUpdate, Update (..), unsafeTypedUpdate, typedUpdate', typedUpdate, update', update,
typedUpdateAllColumn, derivedUpdateAllColumn', derivedUpdateAllColumn, typedUpdateAllColumn, updateAllColumn', updateAllColumn,
updateSQL, updateSQL,
-- * Typed insert statement -- * Typed insert statement
Insert (..), untypeChunkInsert, chunkSizeOfInsert, Insert (..), untypeChunkInsert, chunkSizeOfInsert,
unsafeTypedInsert', unsafeTypedInsert, typedInsert', typedInsert, derivedInsert, unsafeTypedInsert', unsafeTypedInsert, typedInsert', typedInsert, insert,
typedInsertValue', typedInsertValue, derivedInsertValue', derivedInsertValue, typedInsertValue', typedInsertValue, insertValue', insertValue,
InsertQuery (..), unsafeTypedInsertQuery, typedInsertQuery', typedInsertQuery, derivedInsertQuery, InsertQuery (..), unsafeTypedInsertQuery, typedInsertQuery', typedInsertQuery, insertQuery,
insertQuerySQL, insertQuerySQL,
-- * Typed delete statement -- * Typed delete statement
Delete (..), unsafeTypedDelete, typedDelete', typedDelete, derivedDelete', derivedDelete, Delete (..), unsafeTypedDelete, typedDelete', typedDelete, delete', delete,
deleteSQL, deleteSQL,
-- * Generalized interfaces -- * Generalized interfaces
UntypeableNoFetch (..) UntypeableNoFetch (..),
-- * Deprecated
derivedKeyUpdate,
derivedUpdate', derivedUpdate,
derivedUpdateAllColumn', derivedUpdateAllColumn,
derivedInsert,
derivedInsertValue', derivedInsertValue,
derivedInsertQuery,
derivedDelete', derivedDelete,
) where ) where
import Data.Monoid ((<>)) import Data.Monoid ((<>))
@ -107,12 +118,17 @@ typedKeyUpdate tbl key = unsafeTypedKeyUpdate key $ updateOtherThanKeySQL tbl ke
typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r
typedKeyUpdateTable = typedKeyUpdate . tableOf typedKeyUpdateTable = typedKeyUpdate . tableOf
-- derivedKeyUpdate' -- keyUpdate'
-- Config parameter is not yet required for KeyUpdate. -- Config parameter is not yet required for KeyUpdate.
-- | Make typed 'KeyUpdate' from derived table and key columns selector 'Pi'.
keyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r
keyUpdate = typedKeyUpdate derivedTable
{-# DEPRECATED derivedKeyUpdate "use keyUpdate instead of this." #-}
-- | Make typed 'KeyUpdate' from derived table and key columns selector 'Pi'. -- | Make typed 'KeyUpdate' from derived table and key columns selector 'Pi'.
derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r
derivedKeyUpdate = typedKeyUpdate derivedTable derivedKeyUpdate = keyUpdate
-- | Show update SQL string -- | Show update SQL string
instance Show (KeyUpdate p a) where instance Show (KeyUpdate p a) where
@ -142,13 +158,23 @@ targetTable :: TableDerivable r => UpdateTarget p r -> Table r
targetTable = const derivedTable targetTable = const derivedTable
-- | Make typed 'Update' from 'Config', derived table and 'AssignStatement' -- | Make typed 'Update' from 'Config', derived table and 'AssignStatement'
derivedUpdate' :: TableDerivable r => Config -> AssignStatement r (PlaceHolders p) -> Update p update' :: TableDerivable r => Config -> AssignStatement r (PlaceHolders p) -> Update p
derivedUpdate' config utc = typedUpdate' config (targetTable ut) ut where update' config utc = typedUpdate' config (targetTable ut) ut where
ut = updateTarget' utc ut = updateTarget' utc
{-# DEPRECATED derivedUpdate' "use `update'` instead of this." #-}
-- | Make typed 'Update' from 'Config', derived table and 'AssignStatement'
derivedUpdate' :: TableDerivable r => Config -> AssignStatement r (PlaceHolders p) -> Update p
derivedUpdate' = update'
-- | Make typed 'Update' from 'defaultConfig', derived table and 'AssignStatement'
update :: TableDerivable r => AssignStatement r (PlaceHolders p) -> Update p
update = derivedUpdate' defaultConfig
{-# DEPRECATED derivedUpdate "use `update` instead of this." #-}
-- | Make typed 'Update' from 'defaultConfig', derived table and 'AssignStatement' -- | Make typed 'Update' from 'defaultConfig', derived table and 'AssignStatement'
derivedUpdate :: TableDerivable r => AssignStatement r (PlaceHolders p) -> Update p derivedUpdate :: TableDerivable r => AssignStatement r (PlaceHolders p) -> Update p
derivedUpdate = derivedUpdate' defaultConfig derivedUpdate = update
-- | Make typed 'Update' from 'Config', 'Table' and 'Restriction'. -- | Make typed 'Update' from 'Config', 'Table' and 'Restriction'.
@ -168,20 +194,37 @@ typedUpdateAllColumn :: PersistableWidth r
-> Update (r, p) -> Update (r, p)
typedUpdateAllColumn tbl r = typedUpdate tbl $ liftTargetAllColumn' r typedUpdateAllColumn tbl r = typedUpdate tbl $ liftTargetAllColumn' r
-- | Make typed 'Update' from 'Config', derived table and 'AssignStatement'.
-- Update target is all column.
updateAllColumn' :: (PersistableWidth r, TableDerivable r)
=> Config
-> RestrictedStatement r (PlaceHolders p)
-> Update (r, p)
updateAllColumn' config = typedUpdateAllColumn' config derivedTable .restriction'
{-# DEPRECATED derivedUpdateAllColumn' "use `updateAllColumn'` instead of this." #-}
-- | Make typed 'Update' from 'Config', derived table and 'AssignStatement'. -- | Make typed 'Update' from 'Config', derived table and 'AssignStatement'.
-- Update target is all column. -- Update target is all column.
derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r) derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r)
=> Config => Config
-> RestrictedStatement r (PlaceHolders p) -> RestrictedStatement r (PlaceHolders p)
-> Update (r, p) -> Update (r, p)
derivedUpdateAllColumn' config = typedUpdateAllColumn' config derivedTable .restriction' derivedUpdateAllColumn' = updateAllColumn'
-- | Make typed 'Update' from 'defaultConfig', derived table and 'AssignStatement'.
-- Update target is all column.
updateAllColumn :: (PersistableWidth r, TableDerivable r)
=> RestrictedStatement r (PlaceHolders p)
-> Update (r, p)
updateAllColumn = derivedUpdateAllColumn' defaultConfig
{-# DEPRECATED derivedUpdateAllColumn "use `updateAllColumn` instead of this." #-}
-- | Make typed 'Update' from 'defaultConfig', derived table and 'AssignStatement'. -- | Make typed 'Update' from 'defaultConfig', derived table and 'AssignStatement'.
-- Update target is all column. -- Update target is all column.
derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r) derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r)
=> RestrictedStatement r (PlaceHolders p) => RestrictedStatement r (PlaceHolders p)
-> Update (r, p) -> Update (r, p)
derivedUpdateAllColumn = derivedUpdateAllColumn' defaultConfig derivedUpdateAllColumn = updateAllColumn
-- | Show update SQL string -- | Show update SQL string
instance Show (Update p) where instance Show (Update p) where
@ -220,9 +263,14 @@ typedInsert' config tbl =
typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r' typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r'
typedInsert = typedInsert' defaultConfig typedInsert = typedInsert' defaultConfig
-- | Table type inferred 'Insert'.
insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'
insert = typedInsert derivedTable
{-# DEPRECATED derivedInsert "use `insert` instead of this." #-}
-- | Table type inferred 'Insert'. -- | Table type inferred 'Insert'.
derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r' derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'
derivedInsert = typedInsert derivedTable derivedInsert = insert
-- | Make typed 'Insert' from 'Config', 'Table' and monadic builded 'InsertTarget' object. -- | Make typed 'Insert' from 'Config', 'Table' and monadic builded 'InsertTarget' object.
typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p
@ -238,15 +286,25 @@ typedInsertValue :: Table r -> InsertTarget p r -> Insert p
typedInsertValue = typedInsertValue' defaultConfig typedInsertValue = typedInsertValue' defaultConfig
-- | Make typed 'Insert' from 'Config', derived table and monadic builded 'Register' object. -- | Make typed 'Insert' from 'Config', derived table and monadic builded 'Register' object.
derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p
derivedInsertValue' config rs = typedInsertValue' config (rt rs) $ insertTarget' rs insertValue' config rs = typedInsertValue' config (rt rs) $ insertTarget' rs
where where
rt :: TableDerivable r => Register r (PlaceHolders p) -> Table r rt :: TableDerivable r => Register r (PlaceHolders p) -> Table r
rt = const derivedTable rt = const derivedTable
{-# DEPRECATED derivedInsertValue' "use `insertValue'` instead of this." #-}
-- | Make typed 'Insert' from 'Config', derived table and monadic builded 'Register' object.
derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p
derivedInsertValue' = insertValue'
-- | Make typed 'Insert' from 'defaultConfig', derived table and monadic builded 'Register' object.
insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p
insertValue = derivedInsertValue' defaultConfig
{-# DEPRECATED derivedInsertValue "use `insertValue` instead of this." #-}
-- | Make typed 'Insert' from 'defaultConfig', derived table and monadic builded 'Register' object. -- | Make typed 'Insert' from 'defaultConfig', derived table and monadic builded 'Register' object.
derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p
derivedInsertValue = derivedInsertValue' defaultConfig derivedInsertValue = insertValue
-- | Show insert SQL string. -- | Show insert SQL string.
instance Show (Insert a) where instance Show (Insert a) where
@ -271,9 +329,14 @@ typedInsertQuery' config tbl pi' rel = unsafeTypedInsertQuery $ insertQuerySQL c
typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p
typedInsertQuery = typedInsertQuery' defaultConfig typedInsertQuery = typedInsertQuery' defaultConfig
-- | Table type inferred 'InsertQuery'.
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
insertQuery = typedInsertQuery derivedTable
{-# DEPRECATED derivedInsertQuery "use `insertQuery` instead of this." #-}
-- | Table type inferred 'InsertQuery'. -- | Table type inferred 'InsertQuery'.
derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
derivedInsertQuery = typedInsertQuery derivedTable derivedInsertQuery = insertQuery
-- | Show insert SQL string. -- | Show insert SQL string.
instance Show (InsertQuery p) where instance Show (InsertQuery p) where
@ -303,13 +366,23 @@ restrictedTable :: TableDerivable r => Restriction p r -> Table r
restrictedTable = const derivedTable restrictedTable = const derivedTable
-- | Make typed 'Delete' from 'Config', derived table and 'RestrictContext' -- | Make typed 'Delete' from 'Config', derived table and 'RestrictContext'
derivedDelete' :: TableDerivable r => Config -> RestrictedStatement r (PlaceHolders p) -> Delete p delete' :: TableDerivable r => Config -> RestrictedStatement r (PlaceHolders p) -> Delete p
derivedDelete' config rc = typedDelete' config (restrictedTable rs) rs where delete' config rc = typedDelete' config (restrictedTable rs) rs where
rs = restriction' rc rs = restriction' rc
{-# DEPRECATED derivedDelete' "use `delete'` instead of this." #-}
-- | Make typed 'Delete' from 'Config', derived table and 'RestrictContext'
derivedDelete' :: TableDerivable r => Config -> RestrictedStatement r (PlaceHolders p) -> Delete p
derivedDelete' = delete'
-- | Make typed 'Delete' from 'defaultConfig', derived table and 'RestrictContext'
delete :: TableDerivable r => RestrictedStatement r (PlaceHolders p) -> Delete p
delete = derivedDelete' defaultConfig
{-# DEPRECATED derivedDelete "use `delete` instead of this." #-}
-- | Make typed 'Delete' from 'defaultConfig', derived table and 'RestrictContext' -- | Make typed 'Delete' from 'defaultConfig', derived table and 'RestrictContext'
derivedDelete :: TableDerivable r => RestrictedStatement r (PlaceHolders p) -> Delete p derivedDelete :: TableDerivable r => RestrictedStatement r (PlaceHolders p) -> Delete p
derivedDelete = derivedDelete' defaultConfig derivedDelete = delete
-- | Show delete SQL string -- | Show delete SQL string
instance Show (Delete p) where instance Show (Delete p) where