-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Simple storage interface to PostgreSQL
--
-- Simple storage interface to PostgreSQL
@package pg-store
@version 0.2
module Database.PostgreSQL.Store.Types
-- | Value of a cell in the result set
newtype Value
Value :: ByteString -> Value
[valueData] :: Value -> ByteString
-- | Value and type Oid of a cell in the result set
data TypedValue
TypedValue :: Oid -> (Maybe Value) -> TypedValue
-- | Query
data Query a
Query :: ByteString -> [TypedValue] -> Query a
[queryStatement] :: Query a -> ByteString
[queryParams] :: Query a -> [TypedValue]
instance GHC.Classes.Ord (Database.PostgreSQL.Store.Types.Query a)
instance GHC.Classes.Eq (Database.PostgreSQL.Store.Types.Query a)
instance GHC.Show.Show (Database.PostgreSQL.Store.Types.Query a)
instance GHC.Classes.Ord Database.PostgreSQL.Store.Types.TypedValue
instance GHC.Classes.Eq Database.PostgreSQL.Store.Types.TypedValue
instance GHC.Show.Show Database.PostgreSQL.Store.Types.TypedValue
instance GHC.Classes.Ord Database.PostgreSQL.Store.Types.Value
instance GHC.Classes.Eq Database.PostgreSQL.Store.Types.Value
instance GHC.Show.Show Database.PostgreSQL.Store.Types.Value
module Database.PostgreSQL.Store.RowParser
-- | Row parser
data RowParser a
-- | Location of an error
data RowErrorLocation
RowErrorLocation :: Column -> Row -> RowErrorLocation
-- | Errors that occur during row parsing
data RowErrorDetail
-- | Underlying RowParser wants more columns than are currently
-- present.
TooFewColumns :: RowErrorDetail
-- | A column value could not be parsed.
ColumnRejected :: TypedValue -> RowErrorDetail
-- | The contents of a column could not be parsed.
ContentsRejected :: (Maybe ByteString) -> RowErrorDetail
-- | An error that occured when parsing a row.
data RowError
RowError :: RowErrorLocation -> RowErrorDetail -> RowError
-- | Retrieve the current row number.
rowNumber :: RowParser Row
-- | Retrieve the current column number.
columnNumber :: RowParser Column
-- | Retrieve the number of columns left.
columnsLeft :: RowParser Column
-- | Fetch the type Oid and value of the current cell. Also
-- advances the cell cursor to the next column.
fetchColumn :: RowParser TypedValue
-- | Fetch the TypedValue associated with the current cell without
-- advancing the cursor.
peekColumn :: RowParser TypedValue
-- | Fetch a column and parse it. Returning Nothing from the
-- provided parser function will cause a ColumnRejected to be
-- raised. Advances the cell cursor to the next column.
parseColumn :: (TypedValue -> Maybe a) -> RowParser a
-- | Fetch the cell's contents without moving the cell cursor.
peekContents :: RowParser (Maybe ByteString)
-- | Like peekContents but moves the cell cursor to the next column.
fetchContents :: RowParser (Maybe ByteString)
-- | Parse the contents of a column (only if present). Returning
-- Nothing from the provided parser function will raise a
-- ContentsRejected. When the cell is NULL, a
-- ContentsRejected is raised aswell.
parseContents :: (ByteString -> Maybe a) -> RowParser a
-- | Point cursor to the next column.
skipColumn :: RowParser ()
-- | Parse the result.
parseResult :: Result -> RowParser a -> ExceptT RowError IO [a]
instance Control.Monad.Error.Class.MonadError Database.PostgreSQL.Store.RowParser.RowError Database.PostgreSQL.Store.RowParser.RowParser
instance GHC.Base.Monad Database.PostgreSQL.Store.RowParser.RowParser
instance GHC.Base.Applicative Database.PostgreSQL.Store.RowParser.RowParser
instance GHC.Base.Functor Database.PostgreSQL.Store.RowParser.RowParser
instance GHC.Classes.Ord Database.PostgreSQL.Store.RowParser.RowError
instance GHC.Classes.Eq Database.PostgreSQL.Store.RowParser.RowError
instance GHC.Show.Show Database.PostgreSQL.Store.RowParser.RowError
instance GHC.Classes.Ord Database.PostgreSQL.Store.RowParser.RowErrorDetail
instance GHC.Classes.Eq Database.PostgreSQL.Store.RowParser.RowErrorDetail
instance GHC.Show.Show Database.PostgreSQL.Store.RowParser.RowErrorDetail
instance GHC.Classes.Ord Database.PostgreSQL.Store.RowParser.RowErrorLocation
instance GHC.Classes.Eq Database.PostgreSQL.Store.RowParser.RowErrorLocation
instance GHC.Show.Show Database.PostgreSQL.Store.RowParser.RowErrorLocation
module Database.PostgreSQL.Store.Query.Builder
-- | Query builder
type QueryBuilder = State BuilderState ()
-- | Insert a piece of SQL.
insertCode :: ByteString -> QueryBuilder
-- | Insert a parameter placeholder into the code and attach the typed
-- value to the query.
insertTypedValue :: TypedValue -> QueryBuilder
-- | Same as insertTypedValue but untyped.
insertValue :: Value -> QueryBuilder
-- | Extension of insertValue which will add a type hint to the
-- parameter placeholder.
insertValue' :: ByteString -> Value -> QueryBuilder
-- | Insert a quote into the code.
insertQuote :: ByteString -> QueryBuilder
-- | Insert a name into the code. It will be surrounded by double quotes if
-- necessary.
insertName :: ByteString -> QueryBuilder
-- | Join several builders into a comma-seperated list.
insertCommaSeperated :: [QueryBuilder] -> QueryBuilder
-- | a can be instantiated using the query builder.
class FromQueryBuilder a
buildQuery :: FromQueryBuilder a => QueryBuilder -> a
instance Database.PostgreSQL.Store.Query.Builder.FromQueryBuilder Database.PostgreSQL.Store.Query.Builder.QueryBuilder
instance Database.PostgreSQL.Store.Query.Builder.FromQueryBuilder Data.ByteString.Internal.ByteString
instance Database.PostgreSQL.Store.Query.Builder.FromQueryBuilder (Data.ByteString.Internal.ByteString, [Database.PostgreSQL.Store.Types.TypedValue])
instance Database.PostgreSQL.Store.Query.Builder.FromQueryBuilder (Database.PostgreSQL.Store.Types.Query a)
module Database.PostgreSQL.Store.Generics
-- | Analyze the Generic representation of a type to figure out
-- which DataType it needs.
type EntityDataType a = DataType (AnalyzeEntity a)
-- | Make sure a has a safe generic representation. Types that
-- qualify implement Generic and fulfill one of the following
-- criteria:
--
--
-- - single constructor with 1 or more fields
-- - multiple constructors with no fields
--
--
-- This constraint is mostly utilized to give the user more information
-- about why their type has been rejected.
type GenericEntity a = (Generic a, GDataType (AnalyzeEntity a), DataTypeRep (AnalyzeEntity a) ~ Rep a)
-- | Build from entity representation.
toGenericEntity :: (GenericEntity a) => EntityDataType a -> a
-- | Convert to entity representation.
fromGenericEntity :: (GenericEntity a) => a -> EntityDataType a
-- | Information about a record
data KRecord
-- | Combination of two records
TCombine :: KRecord -> KRecord -> KRecord
-- | Single element with meta information and type
TSingle :: Meta -> Type -> KRecord
-- | Information about the constructors of an enumeration
data KFlatSum
-- | Combination of values
TChoose :: KFlatSum -> KFlatSum -> KFlatSum
-- | Single value of the enumeration
TValue :: Meta -> KFlatSum
-- | Information about a data type
data KDataType
-- | Record
TRecord :: Meta -> Meta -> KRecord -> KDataType
-- | Enumeration
TFlatSum :: Meta -> KFlatSum -> KDataType
-- | Mappings between a Generic representation and our
-- KRecord-based representation
class GRecord (rec :: KRecord) where type RecordRep rec :: * -> * data Record rec where {
type family RecordRep rec :: * -> *;
data family Record rec;
}
-- | From Generic representation
toRecord :: GRecord rec => RecordRep rec x -> Record rec
-- | To Generic representation
fromRecord :: GRecord rec => Record rec -> RecordRep rec x
-- | Mappings between a Generic representation and our
-- KFlatSum-based representation
class GFlatSum (enum :: KFlatSum) where type FlatSumRep enum :: * -> * data FlatSum enum where {
type family FlatSumRep enum :: * -> *;
data family FlatSum enum;
}
-- | From Generic representation
toFlatSum :: GFlatSum enum => FlatSumRep enum x -> FlatSum enum
-- | To Generic representation
fromFlatSum :: GFlatSum enum => FlatSum enum -> FlatSumRep enum x
-- | Mappings between a Generic representation and our
-- KDataType-based representation
class GDataType (dat :: KDataType) where type DataTypeRep dat :: * -> * data DataType dat where {
type family DataTypeRep dat :: * -> *;
data family DataType dat;
}
-- | From Generic representation
toDataType :: GDataType dat => DataTypeRep dat x -> DataType dat
-- | To Generic representation
fromDataType :: GDataType dat => DataType dat -> DataTypeRep dat x
-- | Analyze the Generic representation of the selectors. Make sure
-- it has 1 or more fields. Then transform it into a KRecord.
-- | Analyze the Generic representation of constructors. Make sure
-- every constructor has zero fields. Then transform it into a
-- KFlatSum.
-- | Analyze the Generic representation of a data type. If only one
-- constructor exists, further analyzing is delegated to
-- AnalyzeRecordRep. When two or more exist, analyzing is
-- performed by AnalyzeFlatSumRep. The results are gather in a
-- KDataType instance.
-- | Analyze the Generic representation of a type, in order to
-- generate its KDataType instance.
type AnalyzeEntity a = AnalyzeDataType a (Rep a)
instance GHC.Show.Show typ => GHC.Show.Show (Database.PostgreSQL.Store.Generics.Record ('Database.PostgreSQL.Store.Generics.TSingle meta typ))
instance (GHC.Show.Show (Database.PostgreSQL.Store.Generics.Record lhs), GHC.Show.Show (Database.PostgreSQL.Store.Generics.Record rhs)) => GHC.Show.Show (Database.PostgreSQL.Store.Generics.Record ('Database.PostgreSQL.Store.Generics.TCombine lhs rhs))
instance GHC.Show.Show (Database.PostgreSQL.Store.Generics.FlatSum ('Database.PostgreSQL.Store.Generics.TValue meta))
instance (GHC.Show.Show (Database.PostgreSQL.Store.Generics.FlatSum lhs), GHC.Show.Show (Database.PostgreSQL.Store.Generics.FlatSum rhs)) => GHC.Show.Show (Database.PostgreSQL.Store.Generics.FlatSum ('Database.PostgreSQL.Store.Generics.TChoose lhs rhs))
instance GHC.Show.Show (Database.PostgreSQL.Store.Generics.Record rec) => GHC.Show.Show (Database.PostgreSQL.Store.Generics.DataType ('Database.PostgreSQL.Store.Generics.TRecord d c rec))
instance GHC.Show.Show (Database.PostgreSQL.Store.Generics.FlatSum enum) => GHC.Show.Show (Database.PostgreSQL.Store.Generics.DataType ('Database.PostgreSQL.Store.Generics.TFlatSum d enum))
instance Database.PostgreSQL.Store.Generics.GRecord ('Database.PostgreSQL.Store.Generics.TSingle meta typ)
instance (Database.PostgreSQL.Store.Generics.GRecord lhs, Database.PostgreSQL.Store.Generics.GRecord rhs) => Database.PostgreSQL.Store.Generics.GRecord ('Database.PostgreSQL.Store.Generics.TCombine lhs rhs)
instance Database.PostgreSQL.Store.Generics.GFlatSum ('Database.PostgreSQL.Store.Generics.TValue meta)
instance (Database.PostgreSQL.Store.Generics.GFlatSum lhs, Database.PostgreSQL.Store.Generics.GFlatSum rhs) => Database.PostgreSQL.Store.Generics.GFlatSum ('Database.PostgreSQL.Store.Generics.TChoose lhs rhs)
instance Database.PostgreSQL.Store.Generics.GRecord rec => Database.PostgreSQL.Store.Generics.GDataType ('Database.PostgreSQL.Store.Generics.TRecord d c rec)
instance Database.PostgreSQL.Store.Generics.GFlatSum enum => Database.PostgreSQL.Store.Generics.GDataType ('Database.PostgreSQL.Store.Generics.TFlatSum d enum)
module Database.PostgreSQL.Store.Entity
-- | An entity that is used as a parameter or result of a query.
class Entity a where insertEntity = insertGeneric parseEntity = parseGeneric
-- | Insert an instance of a into the query.
insertEntity :: Entity a => a -> QueryBuilder
-- | Insert an instance of a into the query.
insertEntity :: (Entity a, GenericEntity a, GEntity (AnalyzeEntity a)) => a -> QueryBuilder
-- | Retrieve an instance of a from the result set.
parseEntity :: Entity a => RowParser a
-- | Retrieve an instance of a from the result set.
parseEntity :: (Entity a, GenericEntity a, GEntity (AnalyzeEntity a)) => RowParser a
-- | Insert generic entity into the query.
insertGeneric :: (GenericEntity a, GEntity (AnalyzeEntity a)) => a -> QueryBuilder
-- | Generic RowParser for an entity.
parseGeneric :: (GenericEntity a, GEntity (AnalyzeEntity a)) => RowParser a
-- | Generic record entity
class GEntityRecord (rec :: KRecord)
gInsertRecord :: GEntityRecord rec => Record rec -> QueryBuilder
gParseRecord :: GEntityRecord rec => RowParser (Record rec)
-- | Generic enumeration entity
class GEntityEnum (enum :: KFlatSum)
gInsertEnum :: GEntityEnum enum => FlatSum enum -> QueryBuilder
gEnumValues :: GEntityEnum enum => [(ByteString, FlatSum enum)]
-- | Generic entity
class GEntity (dat :: KDataType)
gInsertEntity :: GEntity dat => DataType dat -> QueryBuilder
gParseEntity :: GEntity dat => RowParser (DataType dat)
instance Database.PostgreSQL.Store.Entity.Entity typ => Database.PostgreSQL.Store.Entity.GEntityRecord ('Database.PostgreSQL.Store.Generics.TSingle meta typ)
instance (Database.PostgreSQL.Store.Entity.GEntityRecord lhs, Database.PostgreSQL.Store.Entity.GEntityRecord rhs) => Database.PostgreSQL.Store.Entity.GEntityRecord ('Database.PostgreSQL.Store.Generics.TCombine lhs rhs)
instance GHC.TypeLits.KnownSymbol name => Database.PostgreSQL.Store.Entity.GEntityEnum ('Database.PostgreSQL.Store.Generics.TValue ('GHC.Generics.MetaCons name f r))
instance (Database.PostgreSQL.Store.Entity.GEntityEnum lhs, Database.PostgreSQL.Store.Entity.GEntityEnum rhs) => Database.PostgreSQL.Store.Entity.GEntityEnum ('Database.PostgreSQL.Store.Generics.TChoose lhs rhs)
instance Database.PostgreSQL.Store.Entity.GEntityRecord rec => Database.PostgreSQL.Store.Entity.GEntity ('Database.PostgreSQL.Store.Generics.TRecord d c rec)
instance Database.PostgreSQL.Store.Entity.GEntityEnum enum => Database.PostgreSQL.Store.Entity.GEntity ('Database.PostgreSQL.Store.Generics.TFlatSum d enum)
instance (Database.PostgreSQL.Store.Entity.Entity a, Database.PostgreSQL.Store.Entity.Entity b) => Database.PostgreSQL.Store.Entity.Entity (a, b)
instance (Database.PostgreSQL.Store.Entity.Entity a, Database.PostgreSQL.Store.Entity.Entity b, Database.PostgreSQL.Store.Entity.Entity c) => Database.PostgreSQL.Store.Entity.Entity (a, b, c)
instance (Database.PostgreSQL.Store.Entity.Entity a, Database.PostgreSQL.Store.Entity.Entity b, Database.PostgreSQL.Store.Entity.Entity c, Database.PostgreSQL.Store.Entity.Entity d) => Database.PostgreSQL.Store.Entity.Entity (a, b, c, d)
instance (Database.PostgreSQL.Store.Entity.Entity a, Database.PostgreSQL.Store.Entity.Entity b, Database.PostgreSQL.Store.Entity.Entity c, Database.PostgreSQL.Store.Entity.Entity d, Database.PostgreSQL.Store.Entity.Entity e) => Database.PostgreSQL.Store.Entity.Entity (a, b, c, d, e)
instance (Database.PostgreSQL.Store.Entity.Entity a, Database.PostgreSQL.Store.Entity.Entity b, Database.PostgreSQL.Store.Entity.Entity c, Database.PostgreSQL.Store.Entity.Entity d, Database.PostgreSQL.Store.Entity.Entity e, Database.PostgreSQL.Store.Entity.Entity f) => Database.PostgreSQL.Store.Entity.Entity (a, b, c, d, e, f)
instance (Database.PostgreSQL.Store.Entity.Entity a, Database.PostgreSQL.Store.Entity.Entity b, Database.PostgreSQL.Store.Entity.Entity c, Database.PostgreSQL.Store.Entity.Entity d, Database.PostgreSQL.Store.Entity.Entity e, Database.PostgreSQL.Store.Entity.Entity f, Database.PostgreSQL.Store.Entity.Entity g) => Database.PostgreSQL.Store.Entity.Entity (a, b, c, d, e, f, g)
instance Database.PostgreSQL.Store.Entity.Entity Database.PostgreSQL.Store.Query.Builder.QueryBuilder
instance Database.PostgreSQL.Store.Entity.Entity Database.PostgreSQL.Store.Types.Value
instance Database.PostgreSQL.Store.Entity.Entity Database.PostgreSQL.Store.Types.TypedValue
instance Database.PostgreSQL.Store.Entity.Entity a => Database.PostgreSQL.Store.Entity.Entity (GHC.Base.Maybe a)
instance Database.PostgreSQL.Store.Entity.Entity GHC.Types.Bool
instance Database.PostgreSQL.Store.Entity.Entity GHC.Integer.Type.Integer
instance Database.PostgreSQL.Store.Entity.Entity GHC.Types.Int
instance Database.PostgreSQL.Store.Entity.Entity GHC.Int.Int8
instance Database.PostgreSQL.Store.Entity.Entity GHC.Int.Int16
instance Database.PostgreSQL.Store.Entity.Entity GHC.Int.Int32
instance Database.PostgreSQL.Store.Entity.Entity GHC.Int.Int64
instance Database.PostgreSQL.Store.Entity.Entity GHC.Natural.Natural
instance Database.PostgreSQL.Store.Entity.Entity GHC.Types.Word
instance Database.PostgreSQL.Store.Entity.Entity GHC.Word.Word8
instance Database.PostgreSQL.Store.Entity.Entity GHC.Word.Word16
instance Database.PostgreSQL.Store.Entity.Entity GHC.Word.Word32
instance Database.PostgreSQL.Store.Entity.Entity GHC.Word.Word64
instance Database.PostgreSQL.Store.Entity.Entity GHC.Types.Double
instance Database.PostgreSQL.Store.Entity.Entity GHC.Types.Float
instance Database.PostgreSQL.Store.Entity.Entity Data.Scientific.Scientific
instance Database.PostgreSQL.Store.Entity.Entity GHC.Base.String
instance Database.PostgreSQL.Store.Entity.Entity Data.Text.Internal.Text
instance Database.PostgreSQL.Store.Entity.Entity Data.Text.Internal.Lazy.Text
instance Database.PostgreSQL.Store.Entity.Entity Data.ByteString.Internal.ByteString
instance Database.PostgreSQL.Store.Entity.Entity Data.ByteString.Lazy.Internal.ByteString
instance Database.PostgreSQL.Store.Entity.Entity Data.Aeson.Types.Internal.Value
module Database.PostgreSQL.Store.ColumnEntity
-- | Description of a column type
data ColumnType
ColumnType :: ByteString -> Bool -> Maybe (ByteString -> QueryBuilder) -> ColumnType
-- | Type name
[colTypeName] :: ColumnType -> ByteString
-- | NOT NULL constraint present?
[colTypeNotNull] :: ColumnType -> Bool
-- | Produce a check statement body when given a column name
[colTypeCheck] :: ColumnType -> Maybe (ByteString -> QueryBuilder)
-- | Classify a type which can be used as a column in a table.
class (Entity a) => ColumnEntity a
-- | Describe the column type
describeColumnType :: ColumnEntity a => proxy a -> ColumnType
instance GHC.Real.Real Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance GHC.Num.Num Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance GHC.Real.Integral Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance GHC.Enum.Bounded Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance GHC.Enum.Enum Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance GHC.Classes.Ord Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance GHC.Classes.Eq Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance GHC.Read.Read Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance GHC.Show.Show Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance GHC.Real.Real Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance GHC.Num.Num Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance GHC.Real.Integral Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance GHC.Enum.Bounded Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance GHC.Enum.Enum Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance GHC.Classes.Ord Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance GHC.Classes.Eq Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance GHC.Read.Read Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance GHC.Show.Show Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance GHC.Real.Real Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance GHC.Num.Num Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance GHC.Real.Integral Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance GHC.Enum.Bounded Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance GHC.Enum.Enum Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance GHC.Classes.Ord Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance GHC.Classes.Eq Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance GHC.Read.Read Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance GHC.Show.Show Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity a => Database.PostgreSQL.Store.ColumnEntity.ColumnEntity (GHC.Base.Maybe a)
instance Database.PostgreSQL.Store.Entity.Entity Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity Database.PostgreSQL.Store.ColumnEntity.PGInt2
instance Database.PostgreSQL.Store.Entity.Entity Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity Database.PostgreSQL.Store.ColumnEntity.PGInt4
instance Database.PostgreSQL.Store.Entity.Entity Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity Database.PostgreSQL.Store.ColumnEntity.PGInt8
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Types.Bool
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Integer.Type.Integer
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Types.Int
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Int.Int8
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Int.Int16
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Int.Int32
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Int.Int64
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Natural.Natural
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Types.Word
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Word.Word8
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Word.Word16
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Word.Word32
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Word.Word64
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Types.Float
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Types.Double
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity Data.Scientific.Scientific
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity GHC.Base.String
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity Data.Text.Internal.Text
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity Data.Text.Internal.Lazy.Text
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity Data.ByteString.Internal.ByteString
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity Data.ByteString.Lazy.Internal.ByteString
instance Database.PostgreSQL.Store.ColumnEntity.ColumnEntity Data.Aeson.Types.Internal.Value
module Database.PostgreSQL.Store.Table
-- | Desciption of a column
data Column
Column :: ByteString -> ColumnType -> Column
-- | Column name
[colName] :: Column -> ByteString
-- | Column type
[colType] :: Column -> ColumnType
-- | Description of a column type
data ColumnType
ColumnType :: ByteString -> Bool -> Maybe (ByteString -> QueryBuilder) -> ColumnType
-- | Type name
[colTypeName] :: ColumnType -> ByteString
-- | NOT NULL constraint present?
[colTypeNotNull] :: ColumnType -> Bool
-- | Produce a check statement body when given a column name
[colTypeCheck] :: ColumnType -> Maybe (ByteString -> QueryBuilder)
-- | Classify a type which can be used as a column in a table.
class (Entity a) => ColumnEntity a
-- | Describe the column type
describeColumnType :: ColumnEntity a => proxy a -> ColumnType
-- | Description of a table
data Table
Table :: ByteString -> [Column] -> Table
-- | Table name
[tableName] :: Table -> ByteString
-- | Table columns
[tableCols] :: Table -> [Column]
-- | Classify a type which can be used as a table.
class (Entity a) => TableEntity a where describeTableType = describeGenericTable
-- | Describe the table type.
describeTableType :: TableEntity a => proxy a -> Table
-- | Describe the table type.
describeTableType :: (TableEntity a, GenericTable a) => proxy a -> Table
-- | Build the SQL code which describes and creates the table.
buildTableSchema :: Table -> QueryBuilder
-- | Insert a comma-seperated list of the fully qualified column names of a
-- table.
insertColumns :: Table -> QueryBuilder
-- | Similar to insertColumns, but instead it expands the column
-- names on an alias.
insertColumnsOn :: Table -> ByteString -> QueryBuilder
-- | Constraint for generic tables
type GenericTable a = (Generic a, GTable (AnalyzeTable a))
-- | Fetch the table description for a generic table type.
describeGenericTable :: (GenericTable a) => proxy a -> Table
-- | Type-level description of a record
data KColumns
TCombine :: KColumns -> KColumns -> KColumns
TSelector :: Symbol -> Type -> KColumns
-- | Type-level description of a table
data KTable
TTable :: Symbol -> KColumns -> KTable
-- | Provide the means to demote KColumns to a value.
class GColumns (rec :: KColumns)
-- | Instantiate singleton
gDescribeColumns :: GColumns rec => proxy rec -> [Column]
-- | Provide the means to demote KTable to a value.
class GTable (tbl :: KTable)
-- | Instantiate singleton
gDescribeTable :: GTable tbl => proxy tbl -> Table
-- | Check the Generic representation of a record in order to
-- generate an instance of KColumns.
-- | Check the Generic representation of a data type in order to
-- generate an instance of KTable.
-- | Analyzes a type in order to retrieve its KTable representation.
type AnalyzeTable a = AnalyzeTableRep a (Rep a)
instance (GHC.TypeLits.KnownSymbol name, Database.PostgreSQL.Store.ColumnEntity.ColumnEntity typ) => Database.PostgreSQL.Store.Table.GColumns ('Database.PostgreSQL.Store.Table.TSelector name typ)
instance (Database.PostgreSQL.Store.Table.GColumns lhs, Database.PostgreSQL.Store.Table.GColumns rhs) => Database.PostgreSQL.Store.Table.GColumns ('Database.PostgreSQL.Store.Table.TCombine lhs rhs)
instance (GHC.TypeLits.KnownSymbol name, Database.PostgreSQL.Store.Table.GColumns cols) => Database.PostgreSQL.Store.Table.GTable ('Database.PostgreSQL.Store.Table.TTable name cols)
module Database.PostgreSQL.Store.Errand
-- | Error during errand
data ErrandError
-- | No Result has been returned.
NoResult :: ErrandError
-- | A user has thrown an error.
UserError :: String -> ErrandError
-- | Query execution failed.
ExecError :: ExecStatus -> ErrorCode -> ByteString -> ByteString -> ByteString -> ErrandError
-- | Result processing failed.
ParseError :: RowError -> ErrandError
-- | Error codes
data ErrorCode
UnknownErrorCause :: ByteString -> ErrorCode
IntegrityViolation :: ErrorCode
RestrictViolation :: ErrorCode
NotNullViolation :: ErrorCode
ForeignKeyViolation :: ErrorCode
UniqueViolation :: ErrorCode
CheckViolation :: ErrorCode
ExclusionViolation :: ErrorCode
-- | An interaction with the database
data Errand a
-- | Run an errand.
runErrand :: Connection -> Errand a -> IO (Either ErrandError a)
-- | Execute a query and return the internal raw result.
execute :: Query a -> Errand Result
-- | Same as execute but instead of a Result it returns the
-- number of affected rows.
execute' :: Query a -> Errand Int
-- | Execute a query and process its result set.
query :: (Entity a) => Query a -> Errand [a]
-- | Execute a query and process its result set using the provided
-- RowParser.
queryWith :: Query a -> RowParser a -> Errand [a]
-- | Insert a row into a Table.
insert :: (TableEntity a) => a -> Errand Bool
-- | Insert many rows into a Table.
insertMany :: (TableEntity a) => [a] -> Errand Int
-- | Delete all rows of a Table.
deleteAll :: (TableEntity a) => proxy a -> Errand Int
-- | Find every row of a Table.
findAll :: (TableEntity a) => Errand [a]
-- | Create the given Table type.
create :: (TableEntity a) => proxy a -> Errand ()
instance Control.Monad.Error.Class.MonadError Database.PostgreSQL.Store.Errand.ErrandError Database.PostgreSQL.Store.Errand.Errand
instance Control.Monad.IO.Class.MonadIO Database.PostgreSQL.Store.Errand.Errand
instance GHC.Base.Monad Database.PostgreSQL.Store.Errand.Errand
instance GHC.Base.Applicative Database.PostgreSQL.Store.Errand.Errand
instance GHC.Base.Functor Database.PostgreSQL.Store.Errand.Errand
instance GHC.Classes.Eq Database.PostgreSQL.Store.Errand.ErrandError
instance GHC.Show.Show Database.PostgreSQL.Store.Errand.ErrandError
instance GHC.Classes.Eq Database.PostgreSQL.Store.Errand.ErrorCode
instance GHC.Show.Show Database.PostgreSQL.Store.Errand.ErrorCode
module Database.PostgreSQL.Store.Query.TH
-- | Parse a query string in order to produce a QueryBuilder
-- expression.
parseQuery :: String -> Q Exp
-- | Generate queries conveniently. See BuildQuery to find out
-- which types can be produced.
pgsq :: QuasiQuoter
instance GHC.Classes.Ord Database.PostgreSQL.Store.Query.TH.QuerySegment
instance GHC.Classes.Eq Database.PostgreSQL.Store.Query.TH.QuerySegment
instance GHC.Show.Show Database.PostgreSQL.Store.Query.TH.QuerySegment
-- | This module acts solely as a re-export unit.
module Database.PostgreSQL.Store.Query
-- | Cast the query's result type.
castQuery :: Query a -> Query b
module Database.PostgreSQL.Store
-- | An interaction with the database
data Errand a
-- | Run an errand.
runErrand :: Connection -> Errand a -> IO (Either ErrandError a)
-- | Execute a query and return the internal raw result.
execute :: Query a -> Errand Result
-- | Same as execute but instead of a Result it returns the
-- number of affected rows.
execute' :: Query a -> Errand Int
-- | Execute a query and process its result set.
query :: (Entity a) => Query a -> Errand [a]
-- | Execute a query and process its result set using the provided
-- RowParser.
queryWith :: Query a -> RowParser a -> Errand [a]
-- | Insert a row into a Table.
insert :: (TableEntity a) => a -> Errand Bool
-- | Insert many rows into a Table.
insertMany :: (TableEntity a) => [a] -> Errand Int
-- | Delete all rows of a Table.
deleteAll :: (TableEntity a) => proxy a -> Errand Int
-- | Find every row of a Table.
findAll :: (TableEntity a) => Errand [a]
-- | Create the given Table type.
create :: (TableEntity a) => proxy a -> Errand ()
-- | Query
data Query a
Query :: ByteString -> [TypedValue] -> Query a
[queryStatement] :: Query a -> ByteString
[queryParams] :: Query a -> [TypedValue]
-- | Generate queries conveniently. See BuildQuery to find out
-- which types can be produced.
pgsq :: QuasiQuoter
-- | Cast the query's result type.
castQuery :: Query a -> Query b
-- | An entity that is used as a parameter or result of a query.
class Entity a where insertEntity = insertGeneric parseEntity = parseGeneric
-- | Insert an instance of a into the query.
insertEntity :: Entity a => a -> QueryBuilder
-- | Insert an instance of a into the query.
insertEntity :: (Entity a, GenericEntity a, GEntity (AnalyzeEntity a)) => a -> QueryBuilder
-- | Retrieve an instance of a from the result set.
parseEntity :: Entity a => RowParser a
-- | Retrieve an instance of a from the result set.
parseEntity :: (Entity a, GenericEntity a, GEntity (AnalyzeEntity a)) => RowParser a
-- | Classify a type which can be used as a table.
class (Entity a) => TableEntity a where describeTableType = describeGenericTable
-- | Describe the table type.
describeTableType :: TableEntity a => proxy a -> Table
-- | Describe the table type.
describeTableType :: (TableEntity a, GenericTable a) => proxy a -> Table
-- | Classify a type which can be used as a column in a table.
class (Entity a) => ColumnEntity a
-- | Describe the column type
describeColumnType :: ColumnEntity a => proxy a -> ColumnType
-- | Description of a table
data Table
Table :: ByteString -> [Column] -> Table
-- | Table name
[tableName] :: Table -> ByteString
-- | Table columns
[tableCols] :: Table -> [Column]
-- | Description of a column type
data ColumnType
ColumnType :: ByteString -> Bool -> Maybe (ByteString -> QueryBuilder) -> ColumnType
-- | Type name
[colTypeName] :: ColumnType -> ByteString
-- | NOT NULL constraint present?
[colTypeNotNull] :: ColumnType -> Bool
-- | Produce a check statement body when given a column name
[colTypeCheck] :: ColumnType -> Maybe (ByteString -> QueryBuilder)
-- | Desciption of a column
data Column
Column :: ByteString -> ColumnType -> Column
-- | Column name
[colName] :: Column -> ByteString
-- | Column type
[colType] :: Column -> ColumnType
-- | Error during errand
data ErrandError
-- | No Result has been returned.
NoResult :: ErrandError
-- | A user has thrown an error.
UserError :: String -> ErrandError
-- | Query execution failed.
ExecError :: ExecStatus -> ErrorCode -> ByteString -> ByteString -> ByteString -> ErrandError
-- | Result processing failed.
ParseError :: RowError -> ErrandError
-- | Error codes
data ErrorCode
UnknownErrorCause :: ByteString -> ErrorCode
IntegrityViolation :: ErrorCode
RestrictViolation :: ErrorCode
NotNullViolation :: ErrorCode
ForeignKeyViolation :: ErrorCode
UniqueViolation :: ErrorCode
CheckViolation :: ErrorCode
ExclusionViolation :: ErrorCode
data ExecStatus :: *
-- | An error that occured when parsing a row.
data RowError
RowError :: RowErrorLocation -> RowErrorDetail -> RowError
-- | Location of an error
data RowErrorLocation
RowErrorLocation :: Column -> Row -> RowErrorLocation
-- | Errors that occur during row parsing
data RowErrorDetail
-- | Underlying RowParser wants more columns than are currently
-- present.
TooFewColumns :: RowErrorDetail
-- | A column value could not be parsed.
ColumnRejected :: TypedValue -> RowErrorDetail
-- | The contents of a column could not be parsed.
ContentsRejected :: (Maybe ByteString) -> RowErrorDetail