| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
PgSchema.Import
Description
Shared import surface for generated schema modules only.
Do not import this module from handwritten application or library code.
pg-schema tooling emits a schema module (per database or slice) that imports
PgSchema.Import to pull in the type classes, type families, and promoted data
that describe your schema at compile time. That generated module is what your
application should import alongside PgSchema.DML (and optionally
PgSchema.Generation for the codegen executable).
PgSchema.Import is a thin re-export hub: it exists so generated files stay short
and stable across pg-schema versions, and so the generator does not need to
duplicate long import lists from internal modules. It is part of the package’s
exposed-modules only so those generated modules (which live in your project, not
inside this package) can depend on it via ordinary package imports.
If you import PgSchema.Import directly, you bypass the intended layering, gain no extra capability, and risk silent breakage when the re-export set changes. Treat it as an implementation detail of codegen output, not as a public API to build on.
Synopsis
- class (ToStar (TTabs sch), ToStar (TTabRelFroms sch), ToStar (TTabRelTos sch), ToStar (TTabFldDefs sch), ToStar (TTabFlds sch), ToStar (TTabDefs sch), ToStar (TTypes sch), ToStar (Map1 (TTypDefSym1 sch) (TTypes sch))) => CSchema (sch :: k) where
- class (ToStar name, ToStar (TTabDef sch name)) => CTabDef (sch :: k) (name :: NameNSK) where
- data TabDef' s = TabDef {}
- class (ToStar (TDBFieldInfo sch tab name), ToStar tab, ToStar name) => CDBFieldInfo (sch :: k) (tab :: NameNSK) (name :: Symbol) where
- type TDBFieldInfo (sch :: k) (tab :: NameNSK) (name :: Symbol) :: RecFieldK NameNSK
- data FldDef' s = FldDef {
- fdType :: NameNS' s
- fdNullable :: Bool
- fdHasDefault :: Bool
- data RelDef' s = RelDef {}
- class (ToStar name, ToStar (TTypDef sch name)) => CTypDef (sch :: k) (name :: NameNSK) where
- data TypDef' s = TypDef {
- typCategory :: s
- typElem :: Maybe (NameNS' s)
- typEnum :: [s]
- data RecField' s p
- type RecFieldK = RecField' Symbol
- data Ref' s = Ref {}
- class (ToStar (TRelDef sch ref), CTabDef sch (RdFrom (TRelDef sch ref)), CTabDef sch (RdTo (TRelDef sch ref))) => CRelDef (sch :: k) (ref :: NameNSK) where
- class CTabRels (sch :: k) (tab :: NameNSK) where
- data family PGEnum sch (name :: NameNSK)
- type NameNSK = NameNS' Symbol
- type (->>) (ns :: s) (name :: s) = 'NameNS ns name
- type ToStar (a :: k) = (SingKind (KindOf a), SingI a)
CSchema class
class (ToStar (TTabs sch), ToStar (TTabRelFroms sch), ToStar (TTabRelTos sch), ToStar (TTabFldDefs sch), ToStar (TTabFlds sch), ToStar (TTabDefs sch), ToStar (TTypes sch), ToStar (Map1 (TTypDefSym1 sch) (TTypes sch))) => CSchema (sch :: k) Source #
The main class for schema. All DML operations are based on this class. It contains all the information about the schema: tables, relations, fields, types.
This class guarantees that we can demote all the necessary information about the schema from type level to value level.
Instances will be generated by code generation
CTabDef class
class (ToStar name, ToStar (TTabDef sch name)) => CTabDef (sch :: k) (name :: NameNSK) Source #
instances will be generated by code generation
Instances
| CTabDef PgCatalog (PGC "pg_attribute") Source # | |||||
Defined in PgSchema.Schema.Catalog | |||||
| CTabDef PgCatalog (PGC "pg_class") Source # | |||||
Defined in PgSchema.Schema.Catalog | |||||
| CTabDef PgCatalog (PGC "pg_constraint") Source # | |||||
Defined in PgSchema.Schema.Catalog Associated Types
| |||||
| CTabDef PgCatalog (PGC "pg_enum") Source # | |||||
Defined in PgSchema.Schema.Catalog | |||||
| CTabDef PgCatalog (PGC "pg_namespace") Source # | |||||
Defined in PgSchema.Schema.Catalog | |||||
| CTabDef PgCatalog (PGC "pg_type") Source # | |||||
Defined in PgSchema.Schema.Catalog | |||||
Table shape: ordered column names, primary key, unique constraints.
Constructors
| TabDef | |
Instances
| Show s => Show (TabDef' s) Source # | |
| SingKind s => SingKind (TabDef' s) Source # | |
| SingI n => SingI2 ('TabDef n :: [s] -> [[s]] -> TabDef' s) Source # | |
| (SingI n1, SingI n2) => SingI1 ('TabDef n1 n2 :: [[s]] -> TabDef' s) Source # | |
| (SingI n1, SingI n2, SingI n3) => SingI ('TabDef n1 n2 n3 :: TabDef' s) Source # | |
Defined in PgSchema.Schema | |
| type Demote (TabDef' s) Source # | |
Defined in PgSchema.Schema | |
| type Sing Source # | |
Defined in PgSchema.Schema type Sing | |
CDBFieldInfo class
class (ToStar (TDBFieldInfo sch tab name), ToStar tab, ToStar name) => CDBFieldInfo (sch :: k) (tab :: NameNSK) (name :: Symbol) Source #
Schema-level field kind for (sch, tab, field name). Instances are generated by codegen (Gen) or defined manually (e.g. Catalog).
Associated Types
type TDBFieldInfo (sch :: k) (tab :: NameNSK) (name :: Symbol) :: RecFieldK NameNSK Source #
Instances
| (ToStar (TDBFieldInfoPgCatalog t f), ToStar t, ToStar f) => CDBFieldInfo PgCatalog t f Source # | |||||
Defined in PgSchema.Schema.Catalog Associated Types
| |||||
Column-level type and nullability/default flags.
Constructors
| FldDef | |
Fields
| |
Instances
| SingI n => SingI2 ('FldDef n :: Bool -> Bool -> FldDef' s) Source # | |
| (SingI n1, SingI n2) => SingI2 ('Ref n1 n2 :: s -> FldDef' s -> Ref' s) Source # | |
| (SingI n1, SingI n2) => SingI1 ('FldDef n1 n2 :: Bool -> FldDef' s) Source # | |
| Show s => Show (FldDef' s) Source # | |
| SingKind s => SingKind (FldDef' s) Source # | |
| (SingI n1, SingI n2, SingI n3) => SingI1 ('Ref n1 n2 n3 :: FldDef' s -> Ref' s) Source # | |
| SingI1 ('RFPlain :: FldDef' s -> RecField' s p) Source # | |
| (SingI n1, SingI n2, SingI n3) => SingI ('FldDef n1 n2 n3 :: FldDef' s) Source # | |
Defined in PgSchema.Schema | |
| type Demote (FldDef' s) Source # | |
Defined in PgSchema.Schema | |
| type Sing Source # | |
Defined in PgSchema.Schema type Sing | |
Foreign-key-style link between two qualified tables and column mapping.
Constructors
| RelDef | |
Instances
| Show s => Show (RelDef' s) Source # | |
| SingKind s => SingKind (RelDef' s) Source # | |
| SingI n => SingI2 ('RelDef n :: NameNS' s -> [(s, s)] -> RelDef' s) Source # | |
| (SingI n1, SingI n2) => SingI1 ('RelDef n1 n2 :: [(s, s)] -> RelDef' s) Source # | |
| (SingI n1, SingI n2, SingI n3) => SingI ('RelDef n1 n2 n3 :: RelDef' s) Source # | |
Defined in PgSchema.Schema | |
| type Demote (RelDef' s) Source # | |
Defined in PgSchema.Schema | |
| type Sing Source # | |
Defined in PgSchema.Schema type Sing | |
CTypDef class
class (ToStar name, ToStar (TTypDef sch name)) => CTypDef (sch :: k) (name :: NameNSK) Source #
instances will be generated by code generation
Instances
| CTypDef PgCatalog (PGC "bool") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTypDef PgCatalog (PGC "char") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTypDef PgCatalog (PGC "float4") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTypDef PgCatalog (PGC "int2") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTypDef PgCatalog (PGC "int2[]") Source # | |
| CTypDef PgCatalog (PGC "name") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTypDef PgCatalog (PGC "oid") Source # | |
Defined in PgSchema.Schema.Catalog | |
Description of a PostgreSQL type (category, array element, enum labels).
Constructors
| TypDef | |
Instances
| Show s => Show (TypDef' s) Source # | |
| SingKind s => SingKind (TypDef' s) Source # | |
| SingI n => SingI2 ('TypDef n :: Maybe (NameNS' s) -> [s] -> TypDef' s) Source # | |
| (SingI n1, SingI n2) => SingI1 ('TypDef n1 n2 :: [s] -> TypDef' s) Source # | |
| (SingI n1, SingI n2, SingI n3) => SingI ('TypDef n1 n2 n3 :: TypDef' s) Source # | |
Defined in PgSchema.Schema | |
| type Demote (TypDef' s) Source # | |
Defined in PgSchema.Schema | |
| type Sing Source # | |
Defined in PgSchema.Schema type Sing | |
RecField class
Field of a logical record: plain column, aggregate, or relation hop.
Constructors
| RFEmpty s | Placeholder / unnamed slot (depending on schema codegen). |
| RFPlain (FldDef' s) | Ordinary column with |
| RFAggr (FldDef' s) AggrFun Bool | Aggregate field: |
| RFToHere p [Ref' s] | Relation: navigate |
| RFFromHere p [Ref' s] | Relation: navigate |
| RFSelfRef p [Ref' s] | Self-referential relation through path |
Instances
One step of a join path: source column, types, target column.
Constructors
| Ref | |
Instances
| (SingI n1, SingI n2) => SingI2 ('Ref n1 n2 :: s -> FldDef' s -> Ref' s) Source # | |
| SingI2 ('RFFromHere :: k1 -> [Ref' s] -> RecField' s k1) Source # | |
Defined in PgSchema.Schema | |
| SingI2 ('RFSelfRef :: k1 -> [Ref' s] -> RecField' s k1) Source # | |
| SingI2 ('RFToHere :: k1 -> [Ref' s] -> RecField' s k1) Source # | |
| Show s => Show (Ref' s) Source # | |
| SingKind s => SingKind (Ref' s) Source # | |
| (SingI n1, SingI n2, SingI n3) => SingI1 ('Ref n1 n2 n3 :: FldDef' s -> Ref' s) Source # | |
| SingI n => SingI1 ('RFFromHere n :: [Ref' s] -> RecField' s p) Source # | |
Defined in PgSchema.Schema | |
| SingI n => SingI1 ('RFSelfRef n :: [Ref' s] -> RecField' s p) Source # | |
| SingI n => SingI1 ('RFToHere n :: [Ref' s] -> RecField' s p) Source # | |
| (SingI n1, SingI n2, SingI n3, SingI n4) => SingI ('Ref n1 n2 n3 n4 :: Ref' s) Source # | |
Defined in PgSchema.Schema | |
| type Demote (Ref' s) Source # | |
Defined in PgSchema.Schema | |
| type Sing Source # | |
Defined in PgSchema.Schema type Sing | |
TRelDef type family
class (ToStar (TRelDef sch ref), CTabDef sch (RdFrom (TRelDef sch ref)), CTabDef sch (RdTo (TRelDef sch ref))) => CRelDef (sch :: k) (ref :: NameNSK) Source #
Relation definition for relation name ref.
Instances
| CRelDef PgCatalog (PGC "attribute__class") Source # | |
| CRelDef PgCatalog (PGC "attribute__type") Source # | |
| CRelDef PgCatalog (PGC "class__namespace") Source # | |
| CRelDef PgCatalog (PGC "constraint__class") Source # | |
| CRelDef PgCatalog (PGC "constraint__fclass") Source # | |
| CRelDef PgCatalog (PGC "constraint__namespace") Source # | |
| CRelDef PgCatalog (PGC "enum__type") Source # | |
| CRelDef PgCatalog (PGC "type__namespace") Source # | |
CTabRels class
class CTabRels (sch :: k) (tab :: NameNSK) Source #
Instances
| CTabRels PgCatalog (PGC "pg_attribute") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTabRels PgCatalog (PGC "pg_class") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTabRels PgCatalog (PGC "pg_constraint") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTabRels PgCatalog (PGC "pg_enum") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTabRels PgCatalog (PGC "pg_namespace") Source # | |
Defined in PgSchema.Schema.Catalog | |
| CTabRels PgCatalog (PGC "pg_type") Source # | |
Defined in PgSchema.Schema.Catalog | |
PGEnum type
data family PGEnum sch (name :: NameNSK) Source #
Introduce enum database types.
Data instances are produced by schema generation.
You can use these data instances in you records to SELECTINSERTUPSERT data
Instances
| (Read (PGEnum sch t), ToStar t) => FromJSON (PGEnum sch t) Source # | |
Defined in PgSchema.Types | |
| (Show (PGEnum sch t), ToStar t) => ToJSON (PGEnum sch t) Source # | |
| (Read (PGEnum sch n), ToStar n, Typeable sch, Typeable n) => FromField (PGEnum sch n) Source # | |
Defined in PgSchema.Types Methods fromField :: FieldParser (PGEnum sch n) # | |
| (Show (PGEnum sch n), ToStar n) => ToField (PGEnum sch n) Source # | |
Defined in PgSchema.Types | |
| type CanConvert1 sch tab fld n ('TypDef "E" ('Nothing :: Maybe (NameNS' Symbol)) es) (PGEnum sch n) Source # | |
Defined in PgSchema.Types | |