{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE UndecidableInstances #-}
{-| Internal module: ordinary (term-level) ADTs matching the shape of rows returned
when querying PostgreSQL system catalogs during schema introspection.

This is not part of the application-facing @pg-schema@ API; these types are used
in the generation pipeline and in internal plumbing. Application code should not
import this module: field layout may change together with the generator.

The module appears in the package export list for technical reasons (tests, shared
dependencies, hidden modules). Do not rely on it as a library compatibility boundary.
-}
module PgSchema.Schema.Info where

import Data.Text as T
import GHC.Generics
import GHC.Int
import PgSchema.Types


-- | Tables and views info
data PgClass = PgClass
  { PgClass -> "nspname" := Text
class__namespace  :: "nspname" := Text
  , PgClass -> Text
relname           :: Text
  , PgClass -> PgChar
relkind           :: PgChar
  , PgClass -> [PgAttribute]
attribute__class  :: [PgAttribute]
  , PgClass -> [PgConstraint]
constraint__class :: [PgConstraint] }
  deriving (Int -> PgClass -> ShowS
[PgClass] -> ShowS
PgClass -> String
(Int -> PgClass -> ShowS)
-> (PgClass -> String) -> ([PgClass] -> ShowS) -> Show PgClass
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PgClass -> ShowS
showsPrec :: Int -> PgClass -> ShowS
$cshow :: PgClass -> String
show :: PgClass -> String
$cshowList :: [PgClass] -> ShowS
showList :: [PgClass] -> ShowS
Show,PgClass -> PgClass -> Bool
(PgClass -> PgClass -> Bool)
-> (PgClass -> PgClass -> Bool) -> Eq PgClass
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PgClass -> PgClass -> Bool
== :: PgClass -> PgClass -> Bool
$c/= :: PgClass -> PgClass -> Bool
/= :: PgClass -> PgClass -> Bool
Eq,(forall x. PgClass -> Rep PgClass x)
-> (forall x. Rep PgClass x -> PgClass) -> Generic PgClass
forall x. Rep PgClass x -> PgClass
forall x. PgClass -> Rep PgClass x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PgClass -> Rep PgClass x
from :: forall x. PgClass -> Rep PgClass x
$cto :: forall x. Rep PgClass x -> PgClass
to :: forall x. Rep PgClass x -> PgClass
Generic)

data PgClassShort = PgClassShort
  { PgClassShort -> "nspname" := Text
class__namespace :: "nspname" := Text
  , PgClassShort -> Text
relname          :: Text }
  deriving (Int -> PgClassShort -> ShowS
[PgClassShort] -> ShowS
PgClassShort -> String
(Int -> PgClassShort -> ShowS)
-> (PgClassShort -> String)
-> ([PgClassShort] -> ShowS)
-> Show PgClassShort
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PgClassShort -> ShowS
showsPrec :: Int -> PgClassShort -> ShowS
$cshow :: PgClassShort -> String
show :: PgClassShort -> String
$cshowList :: [PgClassShort] -> ShowS
showList :: [PgClassShort] -> ShowS
Show,PgClassShort -> PgClassShort -> Bool
(PgClassShort -> PgClassShort -> Bool)
-> (PgClassShort -> PgClassShort -> Bool) -> Eq PgClassShort
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PgClassShort -> PgClassShort -> Bool
== :: PgClassShort -> PgClassShort -> Bool
$c/= :: PgClassShort -> PgClassShort -> Bool
/= :: PgClassShort -> PgClassShort -> Bool
Eq,(forall x. PgClassShort -> Rep PgClassShort x)
-> (forall x. Rep PgClassShort x -> PgClassShort)
-> Generic PgClassShort
forall x. Rep PgClassShort x -> PgClassShort
forall x. PgClassShort -> Rep PgClassShort x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PgClassShort -> Rep PgClassShort x
from :: forall x. PgClassShort -> Rep PgClassShort x
$cto :: forall x. Rep PgClassShort x -> PgClassShort
to :: forall x. Rep PgClassShort x -> PgClassShort
Generic)

data PgAttribute = PgAttribute
  { PgAttribute -> Text
attname         :: Text
  , PgAttribute -> PgType
attribute__type :: PgType
  , PgAttribute -> Int16
attnum          :: Int16
  , PgAttribute -> Bool
attnotnull      :: Bool
  , PgAttribute -> Bool
atthasdef       :: Bool }
  deriving (Int -> PgAttribute -> ShowS
[PgAttribute] -> ShowS
PgAttribute -> String
(Int -> PgAttribute -> ShowS)
-> (PgAttribute -> String)
-> ([PgAttribute] -> ShowS)
-> Show PgAttribute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PgAttribute -> ShowS
showsPrec :: Int -> PgAttribute -> ShowS
$cshow :: PgAttribute -> String
show :: PgAttribute -> String
$cshowList :: [PgAttribute] -> ShowS
showList :: [PgAttribute] -> ShowS
Show,PgAttribute -> PgAttribute -> Bool
(PgAttribute -> PgAttribute -> Bool)
-> (PgAttribute -> PgAttribute -> Bool) -> Eq PgAttribute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PgAttribute -> PgAttribute -> Bool
== :: PgAttribute -> PgAttribute -> Bool
$c/= :: PgAttribute -> PgAttribute -> Bool
/= :: PgAttribute -> PgAttribute -> Bool
Eq,(forall x. PgAttribute -> Rep PgAttribute x)
-> (forall x. Rep PgAttribute x -> PgAttribute)
-> Generic PgAttribute
forall x. Rep PgAttribute x -> PgAttribute
forall x. PgAttribute -> Rep PgAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PgAttribute -> Rep PgAttribute x
from :: forall x. PgAttribute -> Rep PgAttribute x
$cto :: forall x. Rep PgAttribute x -> PgAttribute
to :: forall x. Rep PgAttribute x -> PgAttribute
Generic)

data PgConstraint = PgConstraint
  { PgConstraint -> "nspname" := Text
constraint__namespace :: "nspname" := Text
  , PgConstraint -> Text
conname               :: Text
  , PgConstraint -> PgChar
contype               :: PgChar
  , PgConstraint -> PgArr Int16
conkey                :: PgArr Int16 }
  deriving (Int -> PgConstraint -> ShowS
[PgConstraint] -> ShowS
PgConstraint -> String
(Int -> PgConstraint -> ShowS)
-> (PgConstraint -> String)
-> ([PgConstraint] -> ShowS)
-> Show PgConstraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PgConstraint -> ShowS
showsPrec :: Int -> PgConstraint -> ShowS
$cshow :: PgConstraint -> String
show :: PgConstraint -> String
$cshowList :: [PgConstraint] -> ShowS
showList :: [PgConstraint] -> ShowS
Show,PgConstraint -> PgConstraint -> Bool
(PgConstraint -> PgConstraint -> Bool)
-> (PgConstraint -> PgConstraint -> Bool) -> Eq PgConstraint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PgConstraint -> PgConstraint -> Bool
== :: PgConstraint -> PgConstraint -> Bool
$c/= :: PgConstraint -> PgConstraint -> Bool
/= :: PgConstraint -> PgConstraint -> Bool
Eq,(forall x. PgConstraint -> Rep PgConstraint x)
-> (forall x. Rep PgConstraint x -> PgConstraint)
-> Generic PgConstraint
forall x. Rep PgConstraint x -> PgConstraint
forall x. PgConstraint -> Rep PgConstraint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PgConstraint -> Rep PgConstraint x
from :: forall x. PgConstraint -> Rep PgConstraint x
$cto :: forall x. Rep PgConstraint x -> PgConstraint
to :: forall x. Rep PgConstraint x -> PgConstraint
Generic)

-- | Types info
data PgType = PgType
  { PgType -> PgOid
oid             :: PgOid
  , PgType -> "nspname" := Text
type__namespace :: "nspname" := Text
  , PgType -> Text
typname         :: Text
  , PgType -> PgChar
typcategory     :: PgChar
  , PgType -> PgOid
typelem         :: PgOid
  , PgType -> [PgEnum]
enum__type      :: [PgEnum] }
  deriving (Int -> PgType -> ShowS
[PgType] -> ShowS
PgType -> String
(Int -> PgType -> ShowS)
-> (PgType -> String) -> ([PgType] -> ShowS) -> Show PgType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PgType -> ShowS
showsPrec :: Int -> PgType -> ShowS
$cshow :: PgType -> String
show :: PgType -> String
$cshowList :: [PgType] -> ShowS
showList :: [PgType] -> ShowS
Show,PgType -> PgType -> Bool
(PgType -> PgType -> Bool)
-> (PgType -> PgType -> Bool) -> Eq PgType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PgType -> PgType -> Bool
== :: PgType -> PgType -> Bool
$c/= :: PgType -> PgType -> Bool
/= :: PgType -> PgType -> Bool
Eq,(forall x. PgType -> Rep PgType x)
-> (forall x. Rep PgType x -> PgType) -> Generic PgType
forall x. Rep PgType x -> PgType
forall x. PgType -> Rep PgType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PgType -> Rep PgType x
from :: forall x. PgType -> Rep PgType x
$cto :: forall x. Rep PgType x -> PgType
to :: forall x. Rep PgType x -> PgType
Generic)

--
data PgEnum = PgEnum
  { PgEnum -> Text
enumlabel     :: Text
  , PgEnum -> Double
enumsortorder :: Double }
  deriving (Int -> PgEnum -> ShowS
[PgEnum] -> ShowS
PgEnum -> String
(Int -> PgEnum -> ShowS)
-> (PgEnum -> String) -> ([PgEnum] -> ShowS) -> Show PgEnum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PgEnum -> ShowS
showsPrec :: Int -> PgEnum -> ShowS
$cshow :: PgEnum -> String
show :: PgEnum -> String
$cshowList :: [PgEnum] -> ShowS
showList :: [PgEnum] -> ShowS
Show,PgEnum -> PgEnum -> Bool
(PgEnum -> PgEnum -> Bool)
-> (PgEnum -> PgEnum -> Bool) -> Eq PgEnum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PgEnum -> PgEnum -> Bool
== :: PgEnum -> PgEnum -> Bool
$c/= :: PgEnum -> PgEnum -> Bool
/= :: PgEnum -> PgEnum -> Bool
Eq,(forall x. PgEnum -> Rep PgEnum x)
-> (forall x. Rep PgEnum x -> PgEnum) -> Generic PgEnum
forall x. Rep PgEnum x -> PgEnum
forall x. PgEnum -> Rep PgEnum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PgEnum -> Rep PgEnum x
from :: forall x. PgEnum -> Rep PgEnum x
$cto :: forall x. Rep PgEnum x -> PgEnum
to :: forall x. Rep PgEnum x -> PgEnum
Generic)

-- | Foreign key info
data PgRelation = PgRelation
  { PgRelation -> "nspname" := Text
constraint__namespace :: "nspname" := Text
  , PgRelation -> Text
conname               :: Text
  , PgRelation -> PgClassShort
constraint__class     :: PgClassShort
  , PgRelation -> PgClassShort
constraint__fclass    :: PgClassShort
  , PgRelation -> PgArr Int16
conkey                :: PgArr Int16
  , PgRelation -> PgArr Int16
confkey               :: PgArr Int16 }
  deriving (Int -> PgRelation -> ShowS
[PgRelation] -> ShowS
PgRelation -> String
(Int -> PgRelation -> ShowS)
-> (PgRelation -> String)
-> ([PgRelation] -> ShowS)
-> Show PgRelation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PgRelation -> ShowS
showsPrec :: Int -> PgRelation -> ShowS
$cshow :: PgRelation -> String
show :: PgRelation -> String
$cshowList :: [PgRelation] -> ShowS
showList :: [PgRelation] -> ShowS
Show,PgRelation -> PgRelation -> Bool
(PgRelation -> PgRelation -> Bool)
-> (PgRelation -> PgRelation -> Bool) -> Eq PgRelation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PgRelation -> PgRelation -> Bool
== :: PgRelation -> PgRelation -> Bool
$c/= :: PgRelation -> PgRelation -> Bool
/= :: PgRelation -> PgRelation -> Bool
Eq,(forall x. PgRelation -> Rep PgRelation x)
-> (forall x. Rep PgRelation x -> PgRelation) -> Generic PgRelation
forall x. Rep PgRelation x -> PgRelation
forall x. PgRelation -> Rep PgRelation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PgRelation -> Rep PgRelation x
from :: forall x. PgRelation -> Rep PgRelation x
$cto :: forall x. Rep PgRelation x -> PgRelation
to :: forall x. Rep PgRelation x -> PgRelation
Generic)