{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Orville.PostgreSQL.PgCatalog.PgSequence
( PgSequence (..)
, pgSequenceTable
, sequencePgClassOidField
)
where
import Data.Int (Int64)
import qualified Database.PostgreSQL.LibPQ as LibPQ
import qualified Orville.PostgreSQL as Orville
import Orville.PostgreSQL.PgCatalog.OidField (oidField, oidTypeField)
data PgSequence = PgSequence
{ PgSequence -> Oid
pgSequenceClassOid :: LibPQ.Oid
, PgSequence -> Oid
pgSequenceTypeOid :: LibPQ.Oid
, PgSequence -> Int64
pgSequenceStart :: Int64
, PgSequence -> Int64
pgSequenceIncrement :: Int64
, PgSequence -> Int64
pgSequenceMax :: Int64
, PgSequence -> Int64
pgSequenceMin :: Int64
, PgSequence -> Int64
pgSequenceCache :: Int64
, PgSequence -> Bool
pgSequenceCycle :: Bool
}
pgSequenceTable :: Orville.TableDefinition (Orville.HasKey LibPQ.Oid) PgSequence PgSequence
pgSequenceTable :: TableDefinition (HasKey Oid) PgSequence PgSequence
pgSequenceTable =
String
-> TableDefinition (HasKey Oid) PgSequence PgSequence
-> TableDefinition (HasKey Oid) PgSequence PgSequence
forall key writeEntity readEntity.
String
-> TableDefinition key writeEntity readEntity
-> TableDefinition key writeEntity readEntity
Orville.setTableSchema String
"pg_catalog" (TableDefinition (HasKey Oid) PgSequence PgSequence
-> TableDefinition (HasKey Oid) PgSequence PgSequence)
-> TableDefinition (HasKey Oid) PgSequence PgSequence
-> TableDefinition (HasKey Oid) PgSequence PgSequence
forall a b. (a -> b) -> a -> b
$
String
-> PrimaryKey Oid
-> SqlMarshaller PgSequence PgSequence
-> TableDefinition (HasKey Oid) PgSequence PgSequence
forall key writeEntity readEntity.
String
-> PrimaryKey key
-> SqlMarshaller writeEntity readEntity
-> TableDefinition (HasKey key) writeEntity readEntity
Orville.mkTableDefinition
String
"pg_sequence"
(FieldDefinition NotNull Oid -> PrimaryKey Oid
forall key. FieldDefinition NotNull key -> PrimaryKey key
Orville.primaryKey FieldDefinition NotNull Oid
oidField)
SqlMarshaller PgSequence PgSequence
pgSequenceMarshaller
pgSequenceMarshaller :: Orville.SqlMarshaller PgSequence PgSequence
pgSequenceMarshaller :: SqlMarshaller PgSequence PgSequence
pgSequenceMarshaller =
Oid
-> Oid
-> Int64
-> Int64
-> Int64
-> Int64
-> Int64
-> Bool
-> PgSequence
PgSequence
(Oid
-> Oid
-> Int64
-> Int64
-> Int64
-> Int64
-> Int64
-> Bool
-> PgSequence)
-> SqlMarshaller PgSequence Oid
-> SqlMarshaller
PgSequence
(Oid
-> Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> Bool -> PgSequence)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PgSequence -> Oid)
-> FieldDefinition NotNull Oid -> SqlMarshaller PgSequence Oid
forall writeEntity fieldValue nullability.
(writeEntity -> fieldValue)
-> FieldDefinition nullability fieldValue
-> SqlMarshaller writeEntity fieldValue
Orville.marshallField PgSequence -> Oid
pgSequenceClassOid FieldDefinition NotNull Oid
sequencePgClassOidField
SqlMarshaller
PgSequence
(Oid
-> Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> Bool -> PgSequence)
-> SqlMarshaller PgSequence Oid
-> SqlMarshaller
PgSequence
(Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> Bool -> PgSequence)
forall a b.
SqlMarshaller PgSequence (a -> b)
-> SqlMarshaller PgSequence a -> SqlMarshaller PgSequence b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PgSequence -> Oid)
-> FieldDefinition NotNull Oid -> SqlMarshaller PgSequence Oid
forall writeEntity fieldValue nullability.
(writeEntity -> fieldValue)
-> FieldDefinition nullability fieldValue
-> SqlMarshaller writeEntity fieldValue
Orville.marshallField PgSequence -> Oid
pgSequenceTypeOid FieldDefinition NotNull Oid
sequenceTypeOidField
SqlMarshaller
PgSequence
(Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> Bool -> PgSequence)
-> SqlMarshaller PgSequence Int64
-> SqlMarshaller
PgSequence (Int64 -> Int64 -> Int64 -> Int64 -> Bool -> PgSequence)
forall a b.
SqlMarshaller PgSequence (a -> b)
-> SqlMarshaller PgSequence a -> SqlMarshaller PgSequence b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PgSequence -> Int64)
-> FieldDefinition NotNull Int64 -> SqlMarshaller PgSequence Int64
forall writeEntity fieldValue nullability.
(writeEntity -> fieldValue)
-> FieldDefinition nullability fieldValue
-> SqlMarshaller writeEntity fieldValue
Orville.marshallField PgSequence -> Int64
pgSequenceStart FieldDefinition NotNull Int64
sequenceStartField
SqlMarshaller
PgSequence (Int64 -> Int64 -> Int64 -> Int64 -> Bool -> PgSequence)
-> SqlMarshaller PgSequence Int64
-> SqlMarshaller
PgSequence (Int64 -> Int64 -> Int64 -> Bool -> PgSequence)
forall a b.
SqlMarshaller PgSequence (a -> b)
-> SqlMarshaller PgSequence a -> SqlMarshaller PgSequence b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PgSequence -> Int64)
-> FieldDefinition NotNull Int64 -> SqlMarshaller PgSequence Int64
forall writeEntity fieldValue nullability.
(writeEntity -> fieldValue)
-> FieldDefinition nullability fieldValue
-> SqlMarshaller writeEntity fieldValue
Orville.marshallField PgSequence -> Int64
pgSequenceIncrement FieldDefinition NotNull Int64
sequenceIncrementField
SqlMarshaller
PgSequence (Int64 -> Int64 -> Int64 -> Bool -> PgSequence)
-> SqlMarshaller PgSequence Int64
-> SqlMarshaller PgSequence (Int64 -> Int64 -> Bool -> PgSequence)
forall a b.
SqlMarshaller PgSequence (a -> b)
-> SqlMarshaller PgSequence a -> SqlMarshaller PgSequence b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PgSequence -> Int64)
-> FieldDefinition NotNull Int64 -> SqlMarshaller PgSequence Int64
forall writeEntity fieldValue nullability.
(writeEntity -> fieldValue)
-> FieldDefinition nullability fieldValue
-> SqlMarshaller writeEntity fieldValue
Orville.marshallField PgSequence -> Int64
pgSequenceMax FieldDefinition NotNull Int64
sequenceMaxField
SqlMarshaller PgSequence (Int64 -> Int64 -> Bool -> PgSequence)
-> SqlMarshaller PgSequence Int64
-> SqlMarshaller PgSequence (Int64 -> Bool -> PgSequence)
forall a b.
SqlMarshaller PgSequence (a -> b)
-> SqlMarshaller PgSequence a -> SqlMarshaller PgSequence b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PgSequence -> Int64)
-> FieldDefinition NotNull Int64 -> SqlMarshaller PgSequence Int64
forall writeEntity fieldValue nullability.
(writeEntity -> fieldValue)
-> FieldDefinition nullability fieldValue
-> SqlMarshaller writeEntity fieldValue
Orville.marshallField PgSequence -> Int64
pgSequenceMin FieldDefinition NotNull Int64
sequenceMinField
SqlMarshaller PgSequence (Int64 -> Bool -> PgSequence)
-> SqlMarshaller PgSequence Int64
-> SqlMarshaller PgSequence (Bool -> PgSequence)
forall a b.
SqlMarshaller PgSequence (a -> b)
-> SqlMarshaller PgSequence a -> SqlMarshaller PgSequence b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PgSequence -> Int64)
-> FieldDefinition NotNull Int64 -> SqlMarshaller PgSequence Int64
forall writeEntity fieldValue nullability.
(writeEntity -> fieldValue)
-> FieldDefinition nullability fieldValue
-> SqlMarshaller writeEntity fieldValue
Orville.marshallField PgSequence -> Int64
pgSequenceCache FieldDefinition NotNull Int64
sequenceCacheField
SqlMarshaller PgSequence (Bool -> PgSequence)
-> SqlMarshaller PgSequence Bool
-> SqlMarshaller PgSequence PgSequence
forall a b.
SqlMarshaller PgSequence (a -> b)
-> SqlMarshaller PgSequence a -> SqlMarshaller PgSequence b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PgSequence -> Bool)
-> FieldDefinition NotNull Bool -> SqlMarshaller PgSequence Bool
forall writeEntity fieldValue nullability.
(writeEntity -> fieldValue)
-> FieldDefinition nullability fieldValue
-> SqlMarshaller writeEntity fieldValue
Orville.marshallField PgSequence -> Bool
pgSequenceCycle FieldDefinition NotNull Bool
sequenceCycleField
sequencePgClassOidField :: Orville.FieldDefinition Orville.NotNull LibPQ.Oid
sequencePgClassOidField :: FieldDefinition NotNull Oid
sequencePgClassOidField =
String -> FieldDefinition NotNull Oid
oidTypeField String
"seqrelid"
sequenceTypeOidField :: Orville.FieldDefinition Orville.NotNull LibPQ.Oid
sequenceTypeOidField :: FieldDefinition NotNull Oid
sequenceTypeOidField =
String -> FieldDefinition NotNull Oid
oidTypeField String
"seqtypid"
sequenceStartField :: Orville.FieldDefinition Orville.NotNull Int64
sequenceStartField :: FieldDefinition NotNull Int64
sequenceStartField =
String -> FieldDefinition NotNull Int64
Orville.bigIntegerField String
"seqstart"
sequenceIncrementField :: Orville.FieldDefinition Orville.NotNull Int64
sequenceIncrementField :: FieldDefinition NotNull Int64
sequenceIncrementField =
String -> FieldDefinition NotNull Int64
Orville.bigIntegerField String
"seqincrement"
sequenceMaxField :: Orville.FieldDefinition Orville.NotNull Int64
sequenceMaxField :: FieldDefinition NotNull Int64
sequenceMaxField =
String -> FieldDefinition NotNull Int64
Orville.bigIntegerField String
"seqmax"
sequenceMinField :: Orville.FieldDefinition Orville.NotNull Int64
sequenceMinField :: FieldDefinition NotNull Int64
sequenceMinField =
String -> FieldDefinition NotNull Int64
Orville.bigIntegerField String
"seqmin"
sequenceCacheField :: Orville.FieldDefinition Orville.NotNull Int64
sequenceCacheField :: FieldDefinition NotNull Int64
sequenceCacheField =
String -> FieldDefinition NotNull Int64
Orville.bigIntegerField String
"seqcache"
sequenceCycleField :: Orville.FieldDefinition Orville.NotNull Bool
sequenceCycleField :: FieldDefinition NotNull Bool
sequenceCycleField =
String -> FieldDefinition NotNull Bool
Orville.booleanField String
"seqcycle"