| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
Opaleye.Manipulation
Description
Inserts, updates and deletes
Please note that Opaleye currently only supports 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;
Synopsis
- runInsert :: Connection -> Insert haskells -> IO haskells
- data Insert haskells = forall fieldsW fieldsR.Insert {- iTable :: Table fieldsW fieldsR
- iRows :: [fieldsW]
- iReturning :: Returning fieldsR haskells
- iOnConflict :: Maybe OnConflict
 
- runUpdate :: Connection -> Update haskells -> IO haskells
- data Update haskells = forall fieldsW fieldsR.Update {- uTable :: Table fieldsW fieldsR
- uUpdateWith :: fieldsR -> fieldsW
- uWhere :: fieldsR -> Field SqlBool
- uReturning :: Returning fieldsR haskells
 
- updateEasy :: Default Updater fieldsR fieldsW => (fieldsR -> fieldsR) -> fieldsR -> fieldsW
- runDelete :: Connection -> Delete haskells -> IO haskells
- data Delete haskells = forall fieldsW fieldsR.Delete {}
- data Returning fields haskells
- rCount :: Returning fieldsR Int64
- rReturning :: Default FromFields fields haskells => (fieldsR -> fields) -> Returning fieldsR [haskells]
- rReturningI :: Default (Inferrable FromFields) fields haskells => (fieldsR -> fields) -> Returning fieldsR [haskells]
- rReturningExplicit :: FromFields fields haskells -> (fieldsR -> fields) -> Returning fieldsR [haskells]
- data OnConflict
- doNothing :: OnConflict
- runInsert_ :: Connection -> Insert haskells -> IO haskells
- runUpdate_ :: Connection -> Update haskells -> IO haskells
- runDelete_ :: Connection -> Delete haskells -> IO haskells
- data OnConflict = DoNothing
Insert
Arguments
| :: Connection | |
| -> Insert haskells | |
| -> IO haskells | Returns a type that depends on the  | 
Constructors
| forall fieldsW fieldsR. Insert | |
| Fields 
 | |
Update
Arguments
| :: Connection | |
| -> Update haskells | |
| -> IO haskells | Returns a type that depends on the  | 
Constructors
| forall fieldsW fieldsR. Update | |
| Fields 
 | |
updateEasy :: Default Updater fieldsR fieldsW => (fieldsR -> fieldsR) -> fieldsR -> fieldsW Source #
A convenient wrapper for writing your update function.
 updateEasy protects you from accidentally updating an
 optionalTableField with Nothing (i.e. SQL
 DEFAULT).  See uUpdateWith.
uUpdateWith = updateEasy (\... -> ...)
Delete
Arguments
| :: Connection | |
| -> Delete haskells | |
| -> IO haskells | Returns a type that depends on the  | 
Returning
rReturning :: Default FromFields fields haskells => (fieldsR -> fields) -> Returning fieldsR [haskells] Source #
Return a function of the inserted or updated rows
rReturning's use of the Default FromFieldsrReturning.
rReturningI :: Default (Inferrable FromFields) fields haskells => (fieldsR -> fields) -> Returning fieldsR [haskells] Source #
Like rReturning but with better inference properties.  On the
 other hand the mapping from SQL fields to Haskell types is less
 flexible.
rReturningExplicit :: FromFields fields haskells -> (fieldsR -> fields) -> Returning fieldsR [haskells] Source #
Return a function of the inserted or updated rows.  Explicit
 version.  You probably just want to use rReturning instead.
On conflict
Currently doNothing is the
 only conflict action supported by
 Opaleye.
data OnConflict Source #
Deprecated
runInsert_ :: Connection -> Insert haskells -> IO haskells Source #
Deprecated: Use runInsert instead.  Will be removed in 0.11.
runUpdate_ :: Connection -> Update haskells -> IO haskells Source #
Deprecated: Use runUpdate instead.  Will be removed in 0.11.
runDelete_ :: Connection -> Delete haskells -> IO haskells Source #
Deprecated: Use runDelete instead.  Will be removed in 0.11.
DoNothing
Use doNothing instead.
 DoNothing will be removed in
 version 0.11.
data OnConflict Source #
Constructors
| DoNothing | Deprecated: Use  ON CONFLICT DO NOTHING |