quokka-0.1.2: Test helpers which help generate data for projects that use postgresql.

Copyright© 2019 Shirren Premaratne
LicenseMIT
MaintainerShirren Premaratne <shirren.premaratne@gmail.com>
Stabilitystable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Quokka.Functions

Description

Functions to generate Postgres data via the postgres-simple library.

Synopsis

Documentation

build :: ToRow q => Connection -> ParentTable -> [q] -> IO [Id] Source #

Build a prepared statement to insert data into the database`

build1 :: ToRow q => Connection -> ParentTable -> q -> IO (Maybe Id) Source #

Similar to the build function but we only ever return a single optional result, and only take 1 value.

buildWith1Rel :: ToRow q => Connection -> ParentTable -> ChildTable -> [q] -> IO [Id] Source #

Build a prepared statement for a child table with a single foreign key to the nominated parent table.

buildWith1CustomRel :: ToRow q => Connection -> Relation -> ChildTable -> [q] -> IO [Id] Source #

Build a prepared statement for a child table with a single foreign key to the nominated parent table through a custom relation.

build1With1Rel :: ToRow q => Connection -> ParentTable -> ChildTable -> q -> IO (Maybe Id) Source #

Build a prepared statement for a child table with a single foreign key table

build1With1CustomRel :: ToRow q => Connection -> Relation -> ChildTable -> q -> IO (Maybe Id) Source #

Build a prepared statement for a child table with a single foreign key table mapped through a custom relation.

buildWithManyRels :: ToRow q => Connection -> [ParentTable] -> ChildTable -> [q] -> IO [Id] Source #

Build a prepared statement for a child table with more than 1 parent

buildWithManyCustomRels :: ToRow q => Connection -> [Relation] -> ChildTable -> [q] -> IO [Id] Source #

Build a prepared statement for a child table with more than 1 parent mapped through a custom relation.

build1WithManyRels :: ToRow q => Connection -> [ParentTable] -> ChildTable -> q -> IO (Maybe Id) Source #

Build a prepared statement for a child table with more than 1 parent

build1WithManyCustomRels :: ToRow q => Connection -> [Relation] -> ChildTable -> q -> IO (Maybe Id) Source #

Build a prepared statement for a child table with more than 1 parent mapped through a custom relation.

delete :: Connection -> Table -> IO Int64 Source #

Perform a truncate with cascade action on the Table

deleteStatement :: Table -> Query Source #

Generate a delete statement for a table

id' :: [Id] -> Int Source #

Helper function to extract the underlying Int value from the first value in the list

insertStatement :: ParentTable -> Query Source #

Create an insert statement for a table

insertStatementWith1Rel :: ParentTable -> ChildTable -> Query Source #

Creates an insert statement for a table, and uses the parent table to also incude a foreign key in the generation of the statement.

insertStatementWith1CustomRel :: Relation -> ChildTable -> Query Source #

Creates an insert statement for a table, and uses the parent table custom relation to build an insert statement for a child table using the relation

insertStatementWithManyRels :: [ParentTable] -> ChildTable -> Query Source #

Creates an insert statement for a table, and uses multiple parent tables to also include foreign keys in the generation of the statement.

insertStatementWithManyCustomRels :: [Relation] -> ChildTable -> Query Source #

Creates an insert statement for a table where the relationship between the parent and child is modelled using a custom key.

mapFromIdToResult :: ParentTable -> [Id] -> [Result] Source #

Function to map from IO [Id] -> IO [Result]