HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Moduleopaleye-0.10.8.0Haskell2010

Opaleye.Manipulation

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;
  • 6 types
  • 12 values
  • Packageopaleye-0.10.8.0
  • Exports18
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceManipulation.hs

Insert

2 declarations

Update

3 declarations
datadata Update haskells
#

Constructors

  • forall fieldsW fieldsR. Update
    • uTable :: Table fieldsW fieldsR
    • uUpdateWith :: fieldsR -> fieldsW

      Be careful: providing Nothing to a field created by Opaleye.Table.optionalTableField updates the field to its default value. Many users have been confused by this because they assume it means that the field is to be left unchanged. For an easier time wrap your update function in updateEasy.

    • uWhere :: fieldsR -> Field SqlBool
    • uReturning :: Returning fieldsR haskells
valueupdateEasy
  1. :: Default Updater fieldsR fieldsW
  2. => (fieldsR -> fieldsR)

    ͘

  3. -> fieldsR
  4. -> fieldsW
#

A convenient wrapper for writing your update function. updateEasy protects you from accidentally updating an Opaleye.Table.optionalTableField with Nothing (i.e. SQL DEFAULT). See uUpdateWith.

uUpdateWith = updateEasy (\... -> ...)

Delete

2 declarations

Returning

5 declarations
datadata Returning fields haskells where
#

Represents a RETURNING statement for a manipulation query.

valuerReturning
  1. :: Default FromFields fields haskells
  2. => (fieldsR -> fields)

    ͘

  3. -> Returning fieldsR [haskells]
#

Return a function of the inserted or updated rows

rReturning's use of the Default FromFields typeclass means that the compiler will have trouble inferring types. It is strongly recommended that you provide full type signatures when using rReturning.

On conflict

2 declarations

Currently doNothing is the only conflict action supported by Opaleye.

Deprecated

3 declarations

DoNothing

Use doNothing instead. DoNothing will be removed in version 0.11.