diff --git a/relational-schemas/relational-schemas.cabal b/relational-schemas/relational-schemas.cabal index 4de266a6..5c803395 100644 --- a/relational-schemas/relational-schemas.cabal +++ b/relational-schemas/relational-schemas.cabal @@ -33,6 +33,7 @@ extra-source-files: ChangeLog.md library exposed-modules: Database.Relational.Schema.DB2Syscat.Columns + Database.Relational.Schema.IBMDB2.Columns Database.Relational.Schema.IBMDB2 Database.Relational.Schema.PgCatalog.PgAttribute @@ -62,8 +63,9 @@ library Database.Relational.Schema.MySQLInfo.Config other-modules: - Database.Relational.Schema.DB2Syscat.Tabconst - Database.Relational.Schema.DB2Syscat.Keycoluse + Database.Relational.Schema.IBMDB2.Config + Database.Relational.Schema.IBMDB2.Tabconst + Database.Relational.Schema.IBMDB2.Keycoluse Database.Relational.Schema.PgCatalog.PgConstraint Database.Relational.Schema.PgCatalog.PgNamespace diff --git a/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Columns.hs b/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Columns.hs index 040d5483..907e871e 100644 --- a/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Columns.hs +++ b/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Columns.hs @@ -1,105 +1,6 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveGeneric #-} +module Database.Relational.Schema.DB2Syscat.Columns + {-# DEPRECATED "import Database.Relational.Schema.IBMDB2.Columns instead of this module." #-} ( + module Database.Relational.Schema.IBMDB2.Columns, + ) where --- | --- Module : Database.Relational.Schema.DB2Syscat.Columns --- Copyright : 2013-2017 Kei Hibino --- License : BSD3 --- --- Maintainer : ex8k.hibino@gmail.com --- Stability : experimental --- Portability : unknown --- --- Generate template of SYSCAT.columns system catalog table. -module Database.Relational.Schema.DB2Syscat.Columns where - -import GHC.Generics (Generic) -import Data.Int (Int16, Int32, Int64) -import Database.Relational.TH (defineTableTypesAndRecord) - -import Database.Relational.Schema.DB2Syscat.Config (config) - - -$(defineTableTypesAndRecord config - "SYSCAT" "columns" - [ - -- column schema type length NULL - -- ------------------------------ --------- ------------------ -------- ----- ------ - -- TABSCHEMA SYSIBM VARCHAR 128 0 No - ("tabschema", [t|String|]), - -- TABNAME SYSIBM VARCHAR 128 0 No - ("tabname", [t|String|]), - -- COLNAME SYSIBM VARCHAR 128 0 No - ("colname", [t|String|]), - -- COLNO SYSIBM SMALLINT 2 0 No - ("colno", [t|Int16|]), - -- TYPESCHEMA SYSIBM VARCHAR 128 0 No - ("typeschema", [t|String|]), - -- TYPENAME SYSIBM VARCHAR 18 0 No - ("typename", [t|String|]), - -- LENGTH SYSIBM INTEGER 4 0 No - ("length", [t|Int32|]), - -- SCALE SYSIBM SMALLINT 2 0 No - ("scale", [t|Int16|]), - -- DEFAULT SYSIBM VARCHAR 254 0 Yes - ("default", [t|Maybe String|]), - -- NULLS SYSIBM CHARACTER 1 0 No - ("nulls", [t|String|]), - -- CODEPAGE SYSIBM SMALLINT 2 0 No - ("codepage", [t|Int16|]), - -- LOGGED SYSIBM CHARACTER 1 0 No - ("logged", [t|String|]), - -- COMPACT SYSIBM CHARACTER 1 0 No - ("compact", [t|String|]), - -- COLCARD SYSIBM BIGINT 8 0 No - ("colcard", [t|Int64|]), - -- HIGH2KEY SYSIBM VARCHAR 254 0 Yes - ("high2key", [t|Maybe String|]), - -- LOW2KEY SYSIBM VARCHAR 254 0 Yes - ("low2key", [t|Maybe String|]), - -- AVGCOLLEN SYSIBM INTEGER 4 0 No - ("avgcollen", [t|Int32|]), - -- KEYSEQ SYSIBM SMALLINT 2 0 Yes - ("keyseq", [t|Maybe Int16|]), - -- PARTKEYSEQ SYSIBM SMALLINT 2 0 Yes - ("partkeyseq", [t|Maybe Int16|]), - -- NQUANTILES SYSIBM SMALLINT 2 0 No - ("nquantiles", [t|Int16|]), - -- NMOSTFREQ SYSIBM SMALLINT 2 0 No - ("nmostfreq", [t|Int16|]), - -- NUMNULLS SYSIBM BIGINT 8 0 No - ("numnulls", [t|Int64|]), - -- TARGET_TYPESCHEMA SYSIBM VARCHAR 128 0 Yes - ("target_typeschema", [t|Maybe String|]), - -- TARGET_TYPENAME SYSIBM VARCHAR 18 0 Yes - ("target_typename", [t|Maybe String|]), - -- SCOPE_TABSCHEMA SYSIBM VARCHAR 128 0 Yes - ("scope_tabschema", [t|Maybe String|]), - -- SCOPE_TABNAME SYSIBM VARCHAR 128 0 Yes - ("scope_tabname", [t|Maybe String|]), - -- SOURCE_TABSCHEMA SYSIBM VARCHAR 128 0 Yes - ("source_tabschema", [t|Maybe String|]), - -- SOURCE_TABNAME SYSIBM VARCHAR 128 0 Yes - ("source_tabname", [t|Maybe String|]), - -- DL_FEATURES SYSIBM CHARACTER 10 0 Yes - ("dl_features", [t|Maybe String|]), - -- SPECIAL_PROPS SYSIBM CHARACTER 8 0 Yes - ("special_props", [t|Maybe String|]), - -- HIDDEN SYSIBM CHARACTER 1 0 No - ("hidden", [t|String|]), - -- INLINE_LENGTH SYSIBM INTEGER 4 0 No - ("inline_length", [t|Int32|]), - -- IDENTITY SYSIBM CHARACTER 1 0 No - ("identity", [t|String|]), - -- GENERATED SYSIBM CHARACTER 1 0 No - ("generated", [t|String|]), - -- TEXT SYSIBM CLOB 65538 0 Yes - ("text", [t|Maybe String|]), - -- REMARKS SYSIBM VARCHAR 254 0 Yes - ("remarks", [t|Maybe String|]) - - ] - [''Show, ''Generic]) +import Database.Relational.Schema.IBMDB2.Columns diff --git a/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Config.hs b/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Config.hs index 91b5d99d..4166aa51 100644 --- a/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Config.hs +++ b/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Config.hs @@ -1,16 +1,6 @@ --- | --- Module : Database.Relational.Schema.DB2Syscat.Config --- Copyright : 2014 Kei Hibino --- License : BSD3 --- --- Maintainer : ex8k.hibino@gmail.com --- Stability : experimental --- Portability : unknown -module Database.Relational.Schema.DB2Syscat.Config (config) where +module Database.Relational.Schema.DB2Syscat.Config + {-# DEPRECATED "import config from Database.Relational.Schema.IBMDB2 instead of this module." #-} ( + config, + ) where -import Database.Relational (Config (..), ProductUnitSupport (..), defaultConfig) - - --- | Configuration parameter against IBM DB2. -config :: Config -config = defaultConfig { productUnitSupport = PUNotSupported } +import Database.Relational.Schema.IBMDB2.Config (config) diff --git a/relational-schemas/src/Database/Relational/Schema/IBMDB2.hs b/relational-schemas/src/Database/Relational/Schema/IBMDB2.hs index c8278942..f8ef2fb8 100644 --- a/relational-schemas/src/Database/Relational/Schema/IBMDB2.hs +++ b/relational-schemas/src/Database/Relational/Schema/IBMDB2.hs @@ -13,6 +13,8 @@ -- table schema and table constraint informations -- from system catalog of IBM DB2. module Database.Relational.Schema.IBMDB2 ( + module Database.Relational.Schema.IBMDB2.Config, + normalizeColumn, notNull, getType, columnsQuerySQL, primaryKeyQuerySQL @@ -32,12 +34,13 @@ import Database.Relational import Control.Applicative ((<|>)) -import Database.Relational.Schema.DB2Syscat.Columns (Columns, columns) -import qualified Database.Relational.Schema.DB2Syscat.Columns as Columns -import Database.Relational.Schema.DB2Syscat.Tabconst (tabconst) -import qualified Database.Relational.Schema.DB2Syscat.Tabconst as Tabconst -import Database.Relational.Schema.DB2Syscat.Keycoluse (keycoluse) -import qualified Database.Relational.Schema.DB2Syscat.Keycoluse as Keycoluse +import Database.Relational.Schema.IBMDB2.Config +import Database.Relational.Schema.IBMDB2.Columns (Columns, columns) +import qualified Database.Relational.Schema.IBMDB2.Columns as Columns +import Database.Relational.Schema.IBMDB2.Tabconst (tabconst) +import qualified Database.Relational.Schema.IBMDB2.Tabconst as Tabconst +import Database.Relational.Schema.IBMDB2.Keycoluse (keycoluse) +import qualified Database.Relational.Schema.IBMDB2.Keycoluse as Keycoluse -- | Mapping between type in DB2 and Haskell type. diff --git a/relational-schemas/src/Database/Relational/Schema/IBMDB2/Columns.hs b/relational-schemas/src/Database/Relational/Schema/IBMDB2/Columns.hs new file mode 100644 index 00000000..e69c91bf --- /dev/null +++ b/relational-schemas/src/Database/Relational/Schema/IBMDB2/Columns.hs @@ -0,0 +1,105 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} + +-- | +-- Module : Database.Relational.Schema.IBMDB2.Columns +-- Copyright : 2013-2017 Kei Hibino +-- License : BSD3 +-- +-- Maintainer : ex8k.hibino@gmail.com +-- Stability : experimental +-- Portability : unknown +-- +-- Generate template of SYSCAT.columns system catalog table. +module Database.Relational.Schema.IBMDB2.Columns where + +import GHC.Generics (Generic) +import Data.Int (Int16, Int32, Int64) +import Database.Relational.TH (defineTableTypesAndRecord) + +import Database.Relational.Schema.IBMDB2.Config (config) + + +$(defineTableTypesAndRecord config + "SYSCAT" "columns" + [ + -- column schema type length NULL + -- ------------------------------ --------- ------------------ -------- ----- ------ + -- TABSCHEMA SYSIBM VARCHAR 128 0 No + ("tabschema", [t|String|]), + -- TABNAME SYSIBM VARCHAR 128 0 No + ("tabname", [t|String|]), + -- COLNAME SYSIBM VARCHAR 128 0 No + ("colname", [t|String|]), + -- COLNO SYSIBM SMALLINT 2 0 No + ("colno", [t|Int16|]), + -- TYPESCHEMA SYSIBM VARCHAR 128 0 No + ("typeschema", [t|String|]), + -- TYPENAME SYSIBM VARCHAR 18 0 No + ("typename", [t|String|]), + -- LENGTH SYSIBM INTEGER 4 0 No + ("length", [t|Int32|]), + -- SCALE SYSIBM SMALLINT 2 0 No + ("scale", [t|Int16|]), + -- DEFAULT SYSIBM VARCHAR 254 0 Yes + ("default", [t|Maybe String|]), + -- NULLS SYSIBM CHARACTER 1 0 No + ("nulls", [t|String|]), + -- CODEPAGE SYSIBM SMALLINT 2 0 No + ("codepage", [t|Int16|]), + -- LOGGED SYSIBM CHARACTER 1 0 No + ("logged", [t|String|]), + -- COMPACT SYSIBM CHARACTER 1 0 No + ("compact", [t|String|]), + -- COLCARD SYSIBM BIGINT 8 0 No + ("colcard", [t|Int64|]), + -- HIGH2KEY SYSIBM VARCHAR 254 0 Yes + ("high2key", [t|Maybe String|]), + -- LOW2KEY SYSIBM VARCHAR 254 0 Yes + ("low2key", [t|Maybe String|]), + -- AVGCOLLEN SYSIBM INTEGER 4 0 No + ("avgcollen", [t|Int32|]), + -- KEYSEQ SYSIBM SMALLINT 2 0 Yes + ("keyseq", [t|Maybe Int16|]), + -- PARTKEYSEQ SYSIBM SMALLINT 2 0 Yes + ("partkeyseq", [t|Maybe Int16|]), + -- NQUANTILES SYSIBM SMALLINT 2 0 No + ("nquantiles", [t|Int16|]), + -- NMOSTFREQ SYSIBM SMALLINT 2 0 No + ("nmostfreq", [t|Int16|]), + -- NUMNULLS SYSIBM BIGINT 8 0 No + ("numnulls", [t|Int64|]), + -- TARGET_TYPESCHEMA SYSIBM VARCHAR 128 0 Yes + ("target_typeschema", [t|Maybe String|]), + -- TARGET_TYPENAME SYSIBM VARCHAR 18 0 Yes + ("target_typename", [t|Maybe String|]), + -- SCOPE_TABSCHEMA SYSIBM VARCHAR 128 0 Yes + ("scope_tabschema", [t|Maybe String|]), + -- SCOPE_TABNAME SYSIBM VARCHAR 128 0 Yes + ("scope_tabname", [t|Maybe String|]), + -- SOURCE_TABSCHEMA SYSIBM VARCHAR 128 0 Yes + ("source_tabschema", [t|Maybe String|]), + -- SOURCE_TABNAME SYSIBM VARCHAR 128 0 Yes + ("source_tabname", [t|Maybe String|]), + -- DL_FEATURES SYSIBM CHARACTER 10 0 Yes + ("dl_features", [t|Maybe String|]), + -- SPECIAL_PROPS SYSIBM CHARACTER 8 0 Yes + ("special_props", [t|Maybe String|]), + -- HIDDEN SYSIBM CHARACTER 1 0 No + ("hidden", [t|String|]), + -- INLINE_LENGTH SYSIBM INTEGER 4 0 No + ("inline_length", [t|Int32|]), + -- IDENTITY SYSIBM CHARACTER 1 0 No + ("identity", [t|String|]), + -- GENERATED SYSIBM CHARACTER 1 0 No + ("generated", [t|String|]), + -- TEXT SYSIBM CLOB 65538 0 Yes + ("text", [t|Maybe String|]), + -- REMARKS SYSIBM VARCHAR 254 0 Yes + ("remarks", [t|Maybe String|]) + + ] + [''Show, ''Generic]) diff --git a/relational-schemas/src/Database/Relational/Schema/IBMDB2/Config.hs b/relational-schemas/src/Database/Relational/Schema/IBMDB2/Config.hs new file mode 100644 index 00000000..dfdfba11 --- /dev/null +++ b/relational-schemas/src/Database/Relational/Schema/IBMDB2/Config.hs @@ -0,0 +1,16 @@ +-- | +-- Module : Database.Relational.Schema.IBMDB2.Config +-- Copyright : 2014 Kei Hibino +-- License : BSD3 +-- +-- Maintainer : ex8k.hibino@gmail.com +-- Stability : experimental +-- Portability : unknown +module Database.Relational.Schema.IBMDB2.Config (config) where + +import Database.Relational (Config (..), ProductUnitSupport (..), defaultConfig) + + +-- | Configuration parameter against IBM DB2. +config :: Config +config = defaultConfig { productUnitSupport = PUNotSupported } diff --git a/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Keycoluse.hs b/relational-schemas/src/Database/Relational/Schema/IBMDB2/Keycoluse.hs similarity index 88% rename from relational-schemas/src/Database/Relational/Schema/DB2Syscat/Keycoluse.hs rename to relational-schemas/src/Database/Relational/Schema/IBMDB2/Keycoluse.hs index 6a4c605c..d6af6fe4 100644 --- a/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Keycoluse.hs +++ b/relational-schemas/src/Database/Relational/Schema/IBMDB2/Keycoluse.hs @@ -16,13 +16,13 @@ -- Generate template of SYSCAT.keycoluse system catalog table. -- Not all columns are mapped to Haskell record. -- Minimum implementation required to generate table constraints. -module Database.Relational.Schema.DB2Syscat.Keycoluse where +module Database.Relational.Schema.IBMDB2.Keycoluse where import GHC.Generics (Generic) import Data.Int (Int16) import Database.Relational.TH (defineTableTypesAndRecord) -import Database.Relational.Schema.DB2Syscat.Config (config) +import Database.Relational.Schema.IBMDB2.Config (config) -- Not all column is mapped. Minimum implementation. diff --git a/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Tabconst.hs b/relational-schemas/src/Database/Relational/Schema/IBMDB2/Tabconst.hs similarity index 89% rename from relational-schemas/src/Database/Relational/Schema/DB2Syscat/Tabconst.hs rename to relational-schemas/src/Database/Relational/Schema/IBMDB2/Tabconst.hs index 8dd30cb0..39cf3ae0 100644 --- a/relational-schemas/src/Database/Relational/Schema/DB2Syscat/Tabconst.hs +++ b/relational-schemas/src/Database/Relational/Schema/IBMDB2/Tabconst.hs @@ -16,12 +16,12 @@ -- Generate template of SYSCAT.tabconst system catalog table. -- Not all columns are mapped to Haskell record. -- Minimum implementation required to generate table constraints. -module Database.Relational.Schema.DB2Syscat.Tabconst where +module Database.Relational.Schema.IBMDB2.Tabconst where import GHC.Generics (Generic) import Database.Relational.TH (defineTableTypesAndRecord) -import Database.Relational.Schema.DB2Syscat.Config (config) +import Database.Relational.Schema.IBMDB2.Config (config) -- Not all column is mapped. Minimum implementation.