| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Opaleye.Manipulation
Description
Inserts, updates and deletes
Please note that you currently you can only INSERT or UPDATE with constant values, not the result of SELECTS. That is, you can generate SQL of the form
INSERT INTO thetable (John, 1);
but not
INSERT INTO thetable
   SELECT John,
   (SELECT num FROM thetable ORDER BY num DESC LIMIT 1) + 1;
- runInsertMany :: Connection -> Table columns columns' -> [columns] -> IO Int64
 - runInsertManyReturning :: Default QueryRunner returned haskells => Connection -> Table columnsW columnsR -> [columnsW] -> (columnsR -> returned) -> IO [haskells]
 - runUpdate :: Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> IO Int64
 - runUpdateReturning :: Default QueryRunner returned haskells => Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> IO [haskells]
 - runDelete :: Connection -> Table a columnsR -> (columnsR -> Column PGBool) -> IO Int64
 - runInsertReturningExplicit :: QueryRunner returned haskells -> Connection -> Table columnsW columnsR -> columnsW -> (columnsR -> returned) -> IO [haskells]
 - runInsertManyReturningExplicit :: QueryRunner returned haskells -> Connection -> Table columnsW columnsR -> [columnsW] -> (columnsR -> returned) -> IO [haskells]
 - runUpdateReturningExplicit :: QueryRunner returned haskells -> Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> IO [haskells]
 - runInsert :: Connection -> Table columns columns' -> columns -> IO Int64
 - runInsertReturning :: Default QueryRunner returned haskells => Connection -> Table columnsW columnsR -> columnsW -> (columnsR -> returned) -> IO [haskells]
 - arrangeInsert :: Table columns a -> columns -> SqlInsert
 - arrangeInsertSql :: Table columns a -> columns -> String
 - arrangeInsertMany :: Table columns a -> NonEmpty columns -> SqlInsert
 - arrangeInsertManySql :: Table columns a -> NonEmpty columns -> String
 - arrangeUpdate :: Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> SqlUpdate
 - arrangeUpdateSql :: Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> String
 - arrangeDelete :: Table a columnsR -> (columnsR -> Column PGBool) -> SqlDelete
 - arrangeDeleteSql :: Table a columnsR -> (columnsR -> Column PGBool) -> String
 - arrangeInsertManyReturning :: Unpackspec returned ignored -> Table columnsW columnsR -> NonEmpty columnsW -> (columnsR -> returned) -> Returning SqlInsert
 - arrangeInsertManyReturningSql :: Unpackspec returned ignored -> Table columnsW columnsR -> NonEmpty columnsW -> (columnsR -> returned) -> String
 - arrangeUpdateReturning :: Unpackspec returned ignored -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> Returning SqlUpdate
 - arrangeUpdateReturningSql :: Unpackspec returned ignored -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> String
 - data Unpackspec columns columns'
 
Documentation
Arguments
| :: Connection | |
| -> Table columns columns' | Table to insert into  | 
| -> [columns] | Rows to insert  | 
| -> IO Int64 | Number of rows inserted  | 
Insert rows into a table
runInsertManyReturning Source #
Arguments
| :: Default QueryRunner returned haskells | |
| => Connection | |
| -> Table columnsW columnsR | Table to insert into  | 
| -> [columnsW] | Rows to insert  | 
| -> (columnsR -> returned) | Function   | 
| -> IO [haskells] | Returned rows after   | 
Insert rows into a table and return a function of the inserted rows
runInsertManyReturning's use of the Default typeclass means that the
 compiler will have trouble inferring types.  It is strongly
 recommended that you provide full type signatures when using
 runInsertManyReturning.
Arguments
| :: Connection | |
| -> Table columnsW columnsR | Table to update  | 
| -> (columnsR -> columnsW) | Update function to apply to chosen rows  | 
| -> (columnsR -> Column PGBool) | Predicate function   | 
| -> IO Int64 | The number of updated rows  | 
Update rows in a table
Arguments
| :: Default QueryRunner returned haskells | |
| => Connection | |
| -> Table columnsW columnsR | Table to update  | 
| -> (columnsR -> columnsW) | Update function to apply to chosen rows  | 
| -> (columnsR -> Column PGBool) | Predicate function   | 
| -> (columnsR -> returned) | Functon   | 
| -> IO [haskells] | Returned rows after   | 
Update rows in a table and return a function of the updated rows
runUpdateReturning's use of the Default typeclass means
 that the compiler will have trouble inferring types.  It is
 strongly recommended that you provide full type signatures when
 using runInsertReturning.
Arguments
| :: Connection | |
| -> Table a columnsR | Table to delete rows from  | 
| -> (columnsR -> Column PGBool) | Predicate function   | 
| -> IO Int64 | The number of deleted rows  | 
Delete rows from a table
runInsertReturningExplicit :: QueryRunner returned haskells -> Connection -> Table columnsW columnsR -> columnsW -> (columnsR -> returned) -> IO [haskells] Source #
You probably don't need this, but can just use
 runInsertReturning instead.  You only need it if you want to run
 an INSERT RETURNING statement but need to be explicit about the
 QueryRunner.
runInsertManyReturningExplicit :: QueryRunner returned haskells -> Connection -> Table columnsW columnsR -> [columnsW] -> (columnsR -> returned) -> IO [haskells] Source #
You probably don't need this, but can just use
 runInsertManyReturning instead.  You only need it if you want to
 run an UPDATE RETURNING statement but need to be explicit about the
 QueryRunner.
runUpdateReturningExplicit :: QueryRunner returned haskells -> Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> IO [haskells] Source #
You probably don't need this, but can just use
 runUpdateReturning instead.  You only need it if you want to run
 an UPDATE RETURNING statement but need to be explicit about the
 QueryRunner.
runInsert :: Connection -> Table columns columns' -> columns -> IO Int64 Source #
Returns the number of rows inserted
This will be deprecated in a future release.  Use runInsertMany instead.
runInsertReturning :: Default QueryRunner returned haskells => Connection -> Table columnsW columnsR -> columnsW -> (columnsR -> returned) -> IO [haskells] Source #
runInsertReturning's use of the Default typeclass means that the
 compiler will have trouble inferring types.  It is strongly
 recommended that you provide full type signatures when using
 runInsertReturning.
This will be deprecated in a future release.  Use
 runInsertManyReturning instead.
arrangeInsert :: Table columns a -> columns -> SqlInsert Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeInsertSql :: Table columns a -> columns -> String Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeInsertMany :: Table columns a -> NonEmpty columns -> SqlInsert Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeInsertManySql :: Table columns a -> NonEmpty columns -> String Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeUpdate :: Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> SqlUpdate Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeUpdateSql :: Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> String Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeDelete :: Table a columnsR -> (columnsR -> Column PGBool) -> SqlDelete Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeDeleteSql :: Table a columnsR -> (columnsR -> Column PGBool) -> String Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeInsertManyReturning :: Unpackspec returned ignored -> Table columnsW columnsR -> NonEmpty columnsW -> (columnsR -> returned) -> Returning SqlInsert Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeInsertManyReturningSql :: Unpackspec returned ignored -> Table columnsW columnsR -> NonEmpty columnsW -> (columnsR -> returned) -> String Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeUpdateReturning :: Unpackspec returned ignored -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> Returning SqlUpdate Source #
For internal use only. Do not use. Will be removed in a subsequent release.
arrangeUpdateReturningSql :: Unpackspec returned ignored -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> String Source #
For internal use only. Do not use. Will be removed in a subsequent release.
data Unpackspec columns columns' Source #
Instances
| Profunctor Unpackspec Source # | |
| ProductProfunctor Unpackspec Source # | |
| SumProfunctor Unpackspec Source # | |
| Default Unpackspec (Column a) (Column a) Source # | |
| Functor (Unpackspec a) Source # | |
| Applicative (Unpackspec a) Source # | |