mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-11-28 22:24:49 +03:00
relational-schemas: add custom modules to pass appropriate DBMS configuration.
This commit is contained in:
parent
bf53da04e7
commit
fb8b894b77
@ -71,6 +71,13 @@ library
|
||||
Database.Relational.Schema.OracleDataDictionary.Config
|
||||
Database.Relational.Schema.MySQLInfo.Config
|
||||
|
||||
Database.Custom.IBMDB2
|
||||
Database.Custom.PostgreSQL
|
||||
Database.Custom.SQLServer
|
||||
Database.Custom.SQLite3
|
||||
Database.Custom.Oracle
|
||||
Database.Custom.MySQL
|
||||
|
||||
other-modules:
|
||||
Database.Relational.Schema.IBMDB2.Config
|
||||
Database.Relational.Schema.IBMDB2.Tabconst
|
||||
|
71
relational-schemas/src/Database/Custom/IBMDB2.hs
Normal file
71
relational-schemas/src/Database/Custom/IBMDB2.hs
Normal file
@ -0,0 +1,71 @@
|
||||
-- |
|
||||
-- Module : Database.Custom.IBMDB2
|
||||
-- Copyright : 2019 Kei Hibino
|
||||
-- License : BSD3
|
||||
--
|
||||
-- Maintainer : ex8k.hibino@gmail.com
|
||||
-- Stability : experimental
|
||||
-- Portability : unknown
|
||||
--
|
||||
-- This module provides custom APIs with appropriate configuration
|
||||
-- for IBMDB2.
|
||||
module Database.Custom.IBMDB2 (
|
||||
module Database.Relational,
|
||||
|
||||
relationalQuery,
|
||||
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH,
|
||||
) where
|
||||
|
||||
import Database.Relational.Schema.IBMDB2.Config (config)
|
||||
import Database.Relational hiding
|
||||
(unique, relationalQuery,
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH, )
|
||||
|
||||
-- | From 'Relation' into typed 'Query' with suffix SQL words.
|
||||
relationalQuery :: Relation p r -> QuerySuffix -> Query p r
|
||||
relationalQuery = relationalQuery_ config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object.
|
||||
insertValue :: TableDerivable r
|
||||
=> Register r (PlaceHolders p)
|
||||
-> Insert p
|
||||
insertValue = insertValue' config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object with no(unit) placeholder.
|
||||
insertValueNoPH :: TableDerivable r
|
||||
=> Register r ()
|
||||
-> Insert ()
|
||||
insertValueNoPH body = insertValue $ body *> return unitPH
|
||||
|
||||
-- | Make 'InsertQuery' from derived table, 'Pi' and 'Relation'.
|
||||
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
|
||||
insertQuery = insertQuery' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation.
|
||||
update :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r (PlaceHolders p))
|
||||
-> Update p
|
||||
update = update' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation with no(unit) placeholder.
|
||||
updateNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r ())
|
||||
-> Update ()
|
||||
updateNoPH body = update $ (return unitPH <*) . body
|
||||
|
||||
-- | Make 'Delete' from derived table and 'Restrict' computation.
|
||||
delete :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict (PlaceHolders p))
|
||||
-> Delete p
|
||||
delete = delete' config
|
||||
|
||||
-- | Make 'Delete' from 'defaultConfig', derived table and 'Restrict' computation with no(unit) placeholder.
|
||||
deleteNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict ())
|
||||
-> Delete ()
|
||||
deleteNoPH body = delete $ (return unitPH <*) . body
|
71
relational-schemas/src/Database/Custom/MySQL.hs
Normal file
71
relational-schemas/src/Database/Custom/MySQL.hs
Normal file
@ -0,0 +1,71 @@
|
||||
-- |
|
||||
-- Module : Database.Custom.MySQL
|
||||
-- Copyright : 2019 Kei Hibino
|
||||
-- License : BSD3
|
||||
--
|
||||
-- Maintainer : ex8k.hibino@gmail.com
|
||||
-- Stability : experimental
|
||||
-- Portability : unknown
|
||||
--
|
||||
-- This module provides custom APIs with appropriate configuration
|
||||
-- for MySQL.
|
||||
module Database.Custom.MySQL (
|
||||
module Database.Relational,
|
||||
|
||||
relationalQuery,
|
||||
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH,
|
||||
) where
|
||||
|
||||
import Database.Relational.Schema.MySQL.Config (config)
|
||||
import Database.Relational hiding
|
||||
(unique, relationalQuery,
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH, )
|
||||
|
||||
-- | From 'Relation' into typed 'Query' with suffix SQL words.
|
||||
relationalQuery :: Relation p r -> QuerySuffix -> Query p r
|
||||
relationalQuery = relationalQuery_ config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object.
|
||||
insertValue :: TableDerivable r
|
||||
=> Register r (PlaceHolders p)
|
||||
-> Insert p
|
||||
insertValue = insertValue' config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object with no(unit) placeholder.
|
||||
insertValueNoPH :: TableDerivable r
|
||||
=> Register r ()
|
||||
-> Insert ()
|
||||
insertValueNoPH body = insertValue $ body *> return unitPH
|
||||
|
||||
-- | Make 'InsertQuery' from derived table, 'Pi' and 'Relation'.
|
||||
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
|
||||
insertQuery = insertQuery' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation.
|
||||
update :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r (PlaceHolders p))
|
||||
-> Update p
|
||||
update = update' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation with no(unit) placeholder.
|
||||
updateNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r ())
|
||||
-> Update ()
|
||||
updateNoPH body = update $ (return unitPH <*) . body
|
||||
|
||||
-- | Make 'Delete' from derived table and 'Restrict' computation.
|
||||
delete :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict (PlaceHolders p))
|
||||
-> Delete p
|
||||
delete = delete' config
|
||||
|
||||
-- | Make 'Delete' from 'defaultConfig', derived table and 'Restrict' computation with no(unit) placeholder.
|
||||
deleteNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict ())
|
||||
-> Delete ()
|
||||
deleteNoPH body = delete $ (return unitPH <*) . body
|
71
relational-schemas/src/Database/Custom/Oracle.hs
Normal file
71
relational-schemas/src/Database/Custom/Oracle.hs
Normal file
@ -0,0 +1,71 @@
|
||||
-- |
|
||||
-- Module : Database.Custom.Oracle
|
||||
-- Copyright : 2019 Kei Hibino
|
||||
-- License : BSD3
|
||||
--
|
||||
-- Maintainer : ex8k.hibino@gmail.com
|
||||
-- Stability : experimental
|
||||
-- Portability : unknown
|
||||
--
|
||||
-- This module provides custom APIs with appropriate configuration
|
||||
-- for Oracle.
|
||||
module Database.Custom.Oracle (
|
||||
module Database.Relational,
|
||||
|
||||
relationalQuery,
|
||||
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH,
|
||||
) where
|
||||
|
||||
import Database.Relational.Schema.Oracle.Config (config)
|
||||
import Database.Relational hiding
|
||||
(unique, relationalQuery,
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH, )
|
||||
|
||||
-- | From 'Relation' into typed 'Query' with suffix SQL words.
|
||||
relationalQuery :: Relation p r -> QuerySuffix -> Query p r
|
||||
relationalQuery = relationalQuery_ config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object.
|
||||
insertValue :: TableDerivable r
|
||||
=> Register r (PlaceHolders p)
|
||||
-> Insert p
|
||||
insertValue = insertValue' config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object with no(unit) placeholder.
|
||||
insertValueNoPH :: TableDerivable r
|
||||
=> Register r ()
|
||||
-> Insert ()
|
||||
insertValueNoPH body = insertValue $ body *> return unitPH
|
||||
|
||||
-- | Make 'InsertQuery' from derived table, 'Pi' and 'Relation'.
|
||||
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
|
||||
insertQuery = insertQuery' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation.
|
||||
update :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r (PlaceHolders p))
|
||||
-> Update p
|
||||
update = update' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation with no(unit) placeholder.
|
||||
updateNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r ())
|
||||
-> Update ()
|
||||
updateNoPH body = update $ (return unitPH <*) . body
|
||||
|
||||
-- | Make 'Delete' from derived table and 'Restrict' computation.
|
||||
delete :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict (PlaceHolders p))
|
||||
-> Delete p
|
||||
delete = delete' config
|
||||
|
||||
-- | Make 'Delete' from 'defaultConfig', derived table and 'Restrict' computation with no(unit) placeholder.
|
||||
deleteNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict ())
|
||||
-> Delete ()
|
||||
deleteNoPH body = delete $ (return unitPH <*) . body
|
71
relational-schemas/src/Database/Custom/PostgreSQL.hs
Normal file
71
relational-schemas/src/Database/Custom/PostgreSQL.hs
Normal file
@ -0,0 +1,71 @@
|
||||
-- |
|
||||
-- Module : Database.Custom.PostgreSQL
|
||||
-- Copyright : 2019 Kei Hibino
|
||||
-- License : BSD3
|
||||
--
|
||||
-- Maintainer : ex8k.hibino@gmail.com
|
||||
-- Stability : experimental
|
||||
-- Portability : unknown
|
||||
--
|
||||
-- This module provides custom APIs with appropriate configuration
|
||||
-- for PostgreSQL.
|
||||
module Database.Custom.PostgreSQL (
|
||||
module Database.Relational,
|
||||
|
||||
relationalQuery,
|
||||
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH,
|
||||
) where
|
||||
|
||||
import Database.Relational.Schema.PostgreSQL.Config (config)
|
||||
import Database.Relational hiding
|
||||
(unique, relationalQuery,
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH, )
|
||||
|
||||
-- | From 'Relation' into typed 'Query' with suffix SQL words.
|
||||
relationalQuery :: Relation p r -> QuerySuffix -> Query p r
|
||||
relationalQuery = relationalQuery_ config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object.
|
||||
insertValue :: TableDerivable r
|
||||
=> Register r (PlaceHolders p)
|
||||
-> Insert p
|
||||
insertValue = insertValue' config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object with no(unit) placeholder.
|
||||
insertValueNoPH :: TableDerivable r
|
||||
=> Register r ()
|
||||
-> Insert ()
|
||||
insertValueNoPH body = insertValue $ body *> return unitPH
|
||||
|
||||
-- | Make 'InsertQuery' from derived table, 'Pi' and 'Relation'.
|
||||
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
|
||||
insertQuery = insertQuery' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation.
|
||||
update :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r (PlaceHolders p))
|
||||
-> Update p
|
||||
update = update' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation with no(unit) placeholder.
|
||||
updateNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r ())
|
||||
-> Update ()
|
||||
updateNoPH body = update $ (return unitPH <*) . body
|
||||
|
||||
-- | Make 'Delete' from derived table and 'Restrict' computation.
|
||||
delete :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict (PlaceHolders p))
|
||||
-> Delete p
|
||||
delete = delete' config
|
||||
|
||||
-- | Make 'Delete' from 'defaultConfig', derived table and 'Restrict' computation with no(unit) placeholder.
|
||||
deleteNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict ())
|
||||
-> Delete ()
|
||||
deleteNoPH body = delete $ (return unitPH <*) . body
|
71
relational-schemas/src/Database/Custom/SQLServer.hs
Normal file
71
relational-schemas/src/Database/Custom/SQLServer.hs
Normal file
@ -0,0 +1,71 @@
|
||||
-- |
|
||||
-- Module : Database.Custom.SQLServer
|
||||
-- Copyright : 2019 Kei Hibino
|
||||
-- License : BSD3
|
||||
--
|
||||
-- Maintainer : ex8k.hibino@gmail.com
|
||||
-- Stability : experimental
|
||||
-- Portability : unknown
|
||||
--
|
||||
-- This module provides custom APIs with appropriate configuration
|
||||
-- for SQLServer.
|
||||
module Database.Custom.SQLServer (
|
||||
module Database.Relational,
|
||||
|
||||
relationalQuery,
|
||||
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH,
|
||||
) where
|
||||
|
||||
import Database.Relational.Schema.SQLServer.Config (config)
|
||||
import Database.Relational hiding
|
||||
(unique, relationalQuery,
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH, )
|
||||
|
||||
-- | From 'Relation' into typed 'Query' with suffix SQL words.
|
||||
relationalQuery :: Relation p r -> QuerySuffix -> Query p r
|
||||
relationalQuery = relationalQuery_ config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object.
|
||||
insertValue :: TableDerivable r
|
||||
=> Register r (PlaceHolders p)
|
||||
-> Insert p
|
||||
insertValue = insertValue' config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object with no(unit) placeholder.
|
||||
insertValueNoPH :: TableDerivable r
|
||||
=> Register r ()
|
||||
-> Insert ()
|
||||
insertValueNoPH body = insertValue $ body *> return unitPH
|
||||
|
||||
-- | Make 'InsertQuery' from derived table, 'Pi' and 'Relation'.
|
||||
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
|
||||
insertQuery = insertQuery' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation.
|
||||
update :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r (PlaceHolders p))
|
||||
-> Update p
|
||||
update = update' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation with no(unit) placeholder.
|
||||
updateNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r ())
|
||||
-> Update ()
|
||||
updateNoPH body = update $ (return unitPH <*) . body
|
||||
|
||||
-- | Make 'Delete' from derived table and 'Restrict' computation.
|
||||
delete :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict (PlaceHolders p))
|
||||
-> Delete p
|
||||
delete = delete' config
|
||||
|
||||
-- | Make 'Delete' from 'defaultConfig', derived table and 'Restrict' computation with no(unit) placeholder.
|
||||
deleteNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict ())
|
||||
-> Delete ()
|
||||
deleteNoPH body = delete $ (return unitPH <*) . body
|
71
relational-schemas/src/Database/Custom/SQLite3.hs
Normal file
71
relational-schemas/src/Database/Custom/SQLite3.hs
Normal file
@ -0,0 +1,71 @@
|
||||
-- |
|
||||
-- Module : Database.Custom.SQLite3
|
||||
-- Copyright : 2019 Kei Hibino
|
||||
-- License : BSD3
|
||||
--
|
||||
-- Maintainer : ex8k.hibino@gmail.com
|
||||
-- Stability : experimental
|
||||
-- Portability : unknown
|
||||
--
|
||||
-- This module provides custom APIs with appropriate configuration
|
||||
-- for SQLite3.
|
||||
module Database.Custom.SQLite3 (
|
||||
module Database.Relational,
|
||||
|
||||
relationalQuery,
|
||||
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH,
|
||||
) where
|
||||
|
||||
import Database.Relational.Schema.SQLite3.Config (config)
|
||||
import Database.Relational hiding
|
||||
(unique, relationalQuery,
|
||||
insertValue, insertValueNoPH, insertQuery,
|
||||
update, updateNoPH,
|
||||
delete, deleteNoPH, )
|
||||
|
||||
-- | From 'Relation' into typed 'Query' with suffix SQL words.
|
||||
relationalQuery :: Relation p r -> QuerySuffix -> Query p r
|
||||
relationalQuery = relationalQuery_ config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object.
|
||||
insertValue :: TableDerivable r
|
||||
=> Register r (PlaceHolders p)
|
||||
-> Insert p
|
||||
insertValue = insertValue' config
|
||||
|
||||
-- | Make 'Insert' from derived table and monadic builded 'Register' object with no(unit) placeholder.
|
||||
insertValueNoPH :: TableDerivable r
|
||||
=> Register r ()
|
||||
-> Insert ()
|
||||
insertValueNoPH body = insertValue $ body *> return unitPH
|
||||
|
||||
-- | Make 'InsertQuery' from derived table, 'Pi' and 'Relation'.
|
||||
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
|
||||
insertQuery = insertQuery' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation.
|
||||
update :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r (PlaceHolders p))
|
||||
-> Update p
|
||||
update = update' config
|
||||
|
||||
-- | Make 'Update' from derived table and 'Assign' computation with no(unit) placeholder.
|
||||
updateNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Assign r ())
|
||||
-> Update ()
|
||||
updateNoPH body = update $ (return unitPH <*) . body
|
||||
|
||||
-- | Make 'Delete' from derived table and 'Restrict' computation.
|
||||
delete :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict (PlaceHolders p))
|
||||
-> Delete p
|
||||
delete = delete' config
|
||||
|
||||
-- | Make 'Delete' from 'defaultConfig', derived table and 'Restrict' computation with no(unit) placeholder.
|
||||
deleteNoPH :: TableDerivable r
|
||||
=> (Record Flat r -> Restrict ())
|
||||
-> Delete ()
|
||||
deleteNoPH body = delete $ (return unitPH <*) . body
|
Loading…
Reference in New Issue
Block a user