{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE UndecidableInstances #-}
module Database.Beam.Backend.SQL.BeamExtensions
( MonadBeamInsertReturning(..)
, MonadBeamUpdateReturning(..)
, MonadBeamDeleteReturning(..)
, BeamHasInsertOnConflict(..)
, SqlSerial(..)
, onConflictUpdateInstead
, onConflictUpdateAll
) where
import Database.Beam.Backend
import Database.Beam.Query
import Database.Beam.Query.Internal
import Database.Beam.Schema
import Database.Beam.Schema.Tables
import Control.Monad.Cont
import Control.Monad.Except
import Control.Monad.Identity
import qualified Control.Monad.RWS.Lazy as Lazy
import qualified Control.Monad.RWS.Strict as Strict
import Control.Monad.Reader
import qualified Control.Monad.State.Lazy as Lazy
import qualified Control.Monad.State.Strict as Strict
import qualified Control.Monad.Writer.Lazy as Lazy
import qualified Control.Monad.Writer.Strict as Strict
import Data.Functor.Const
import Data.Kind (Type)
import Data.Proxy
import Data.Semigroup
class MonadBeam be m =>
MonadBeamInsertReturning be m | m -> be where
runInsertReturningList
:: ( Beamable table
, Projectible be (table (QExpr be ()))
, FromBackendRow be (table Identity) )
=> SqlInsert be table
-> m [table Identity]
instance MonadBeamInsertReturning be m => MonadBeamInsertReturning be (ExceptT e m) where
runInsertReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> ExceptT e m [table Identity]
runInsertReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamInsertReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> m [table Identity]
runInsertReturningList
instance MonadBeamInsertReturning be m => MonadBeamInsertReturning be (ContT r m) where
runInsertReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> ContT r m [table Identity]
runInsertReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamInsertReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> m [table Identity]
runInsertReturningList
instance MonadBeamInsertReturning be m => MonadBeamInsertReturning be (ReaderT r m) where
runInsertReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> ReaderT r m [table Identity]
runInsertReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamInsertReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> m [table Identity]
runInsertReturningList
instance MonadBeamInsertReturning be m => MonadBeamInsertReturning be (Lazy.StateT r m) where
runInsertReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> StateT r m [table Identity]
runInsertReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamInsertReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> m [table Identity]
runInsertReturningList
instance MonadBeamInsertReturning be m => MonadBeamInsertReturning be (Strict.StateT r m) where
runInsertReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> StateT r m [table Identity]
runInsertReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamInsertReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> m [table Identity]
runInsertReturningList
instance (MonadBeamInsertReturning be m, Monoid r)
=> MonadBeamInsertReturning be (Lazy.WriterT r m) where
runInsertReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> WriterT r m [table Identity]
runInsertReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamInsertReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> m [table Identity]
runInsertReturningList
instance (MonadBeamInsertReturning be m, Monoid r)
=> MonadBeamInsertReturning be (Strict.WriterT r m) where
runInsertReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> WriterT r m [table Identity]
runInsertReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamInsertReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> m [table Identity]
runInsertReturningList
instance (MonadBeamInsertReturning be m, Monoid w)
=> MonadBeamInsertReturning be (Lazy.RWST r w s m) where
runInsertReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> RWST r w s m [table Identity]
runInsertReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamInsertReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> m [table Identity]
runInsertReturningList
instance (MonadBeamInsertReturning be m, Monoid w)
=> MonadBeamInsertReturning be (Strict.RWST r w s m) where
runInsertReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> RWST r w s m [table Identity]
runInsertReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamInsertReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlInsert be table -> m [table Identity]
runInsertReturningList
class MonadBeam be m =>
MonadBeamUpdateReturning be m | m -> be where
runUpdateReturningList
:: ( Beamable table
, Projectible be (table (QExpr be ()))
, FromBackendRow be (table Identity) )
=> SqlUpdate be table
-> m [table Identity]
instance MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (ExceptT e m) where
runUpdateReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> ExceptT e m [table Identity]
runUpdateReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamUpdateReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> m [table Identity]
runUpdateReturningList
instance MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (ContT r m) where
runUpdateReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> ContT r m [table Identity]
runUpdateReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamUpdateReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> m [table Identity]
runUpdateReturningList
instance MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (ReaderT r m) where
runUpdateReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> ReaderT r m [table Identity]
runUpdateReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamUpdateReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> m [table Identity]
runUpdateReturningList
instance MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (Lazy.StateT r m) where
runUpdateReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> StateT r m [table Identity]
runUpdateReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamUpdateReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> m [table Identity]
runUpdateReturningList
instance MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (Strict.StateT r m) where
runUpdateReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> StateT r m [table Identity]
runUpdateReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamUpdateReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> m [table Identity]
runUpdateReturningList
instance (MonadBeamUpdateReturning be m, Monoid r)
=> MonadBeamUpdateReturning be (Lazy.WriterT r m) where
runUpdateReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> WriterT r m [table Identity]
runUpdateReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamUpdateReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> m [table Identity]
runUpdateReturningList
instance (MonadBeamUpdateReturning be m, Monoid r)
=> MonadBeamUpdateReturning be (Strict.WriterT r m) where
runUpdateReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> WriterT r m [table Identity]
runUpdateReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamUpdateReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> m [table Identity]
runUpdateReturningList
instance (MonadBeamUpdateReturning be m, Monoid w)
=> MonadBeamUpdateReturning be (Lazy.RWST r w s m) where
runUpdateReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> RWST r w s m [table Identity]
runUpdateReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamUpdateReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> m [table Identity]
runUpdateReturningList
instance (MonadBeamUpdateReturning be m, Monoid w)
=> MonadBeamUpdateReturning be (Strict.RWST r w s m) where
runUpdateReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> RWST r w s m [table Identity]
runUpdateReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamUpdateReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlUpdate be table -> m [table Identity]
runUpdateReturningList
class MonadBeam be m =>
MonadBeamDeleteReturning be m | m -> be where
runDeleteReturningList
:: ( Beamable table
, Projectible be (table (QExpr be ()))
, FromBackendRow be (table Identity) )
=> SqlDelete be table
-> m [table Identity]
instance MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (ExceptT e m) where
runDeleteReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> ExceptT e m [table Identity]
runDeleteReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamDeleteReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> m [table Identity]
runDeleteReturningList
instance MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (ContT r m) where
runDeleteReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> ContT r m [table Identity]
runDeleteReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamDeleteReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> m [table Identity]
runDeleteReturningList
instance MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (ReaderT r m) where
runDeleteReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> ReaderT r m [table Identity]
runDeleteReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamDeleteReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> m [table Identity]
runDeleteReturningList
instance MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (Lazy.StateT r m) where
runDeleteReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> StateT r m [table Identity]
runDeleteReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamDeleteReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> m [table Identity]
runDeleteReturningList
instance MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (Strict.StateT r m) where
runDeleteReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> StateT r m [table Identity]
runDeleteReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamDeleteReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> m [table Identity]
runDeleteReturningList
instance (MonadBeamDeleteReturning be m, Monoid r)
=> MonadBeamDeleteReturning be (Lazy.WriterT r m) where
runDeleteReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> WriterT r m [table Identity]
runDeleteReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamDeleteReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> m [table Identity]
runDeleteReturningList
instance (MonadBeamDeleteReturning be m, Monoid r)
=> MonadBeamDeleteReturning be (Strict.WriterT r m) where
runDeleteReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> WriterT r m [table Identity]
runDeleteReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamDeleteReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> m [table Identity]
runDeleteReturningList
instance (MonadBeamDeleteReturning be m, Monoid w)
=> MonadBeamDeleteReturning be (Lazy.RWST r w s m) where
runDeleteReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> RWST r w s m [table Identity]
runDeleteReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamDeleteReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> m [table Identity]
runDeleteReturningList
instance (MonadBeamDeleteReturning be m, Monoid w)
=> MonadBeamDeleteReturning be (Strict.RWST r w s m) where
runDeleteReturningList :: forall (table :: (* -> *) -> *).
(Beamable table, Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> RWST r w s m [table Identity]
runDeleteReturningList = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be (m :: * -> *) (table :: (* -> *) -> *).
(MonadBeamDeleteReturning be m, Beamable table,
Projectible be (table (QExpr be ())),
FromBackendRow be (table Identity)) =>
SqlDelete be table -> m [table Identity]
runDeleteReturningList
class BeamSqlBackend be => BeamHasInsertOnConflict be where
data SqlConflictTarget be (table :: (Type -> Type) -> Type) :: Type
data SqlConflictAction be (table :: (Type -> Type) -> Type) :: Type
insertOnConflict
:: Beamable table
=> DatabaseEntity be db (TableEntity table)
-> SqlInsertValues be (table (QExpr be s))
-> SqlConflictTarget be table
-> SqlConflictAction be table
-> SqlInsert be table
anyConflict :: SqlConflictTarget be table
conflictingFields
:: Projectible be proj
=> (table (QExpr be QInternal) -> proj)
-> SqlConflictTarget be table
conflictingFieldsWhere
:: Projectible be proj
=> (table (QExpr be QInternal) -> proj)
-> (forall s. table (QExpr be s) -> QExpr be s Bool)
-> SqlConflictTarget be table
onConflictDoNothing :: SqlConflictAction be table
onConflictUpdateSet
:: Beamable table
=> (forall s. table (QField s) -> table (QExpr be s) -> QAssignment be s)
-> SqlConflictAction be table
onConflictUpdateSetWhere
:: Beamable table
=> (forall s. table (QField s) -> table (QExpr be s) -> QAssignment be s)
-> (forall s. table (QField s) -> table (QExpr be s) -> QExpr be s Bool)
-> SqlConflictAction be table
newtype InaccessibleQAssignment be = InaccessibleQAssignment
{ forall be.
InaccessibleQAssignment be
-> [(BeamSqlBackendFieldNameSyntax be,
BeamSqlBackendExpressionSyntax be)]
unInaccessibleQAssignment :: [(BeamSqlBackendFieldNameSyntax be, BeamSqlBackendExpressionSyntax be)]
} deriving (NonEmpty (InaccessibleQAssignment be) -> InaccessibleQAssignment be
InaccessibleQAssignment be
-> InaccessibleQAssignment be -> InaccessibleQAssignment be
forall b.
Integral b =>
b -> InaccessibleQAssignment be -> InaccessibleQAssignment be
forall be.
NonEmpty (InaccessibleQAssignment be) -> InaccessibleQAssignment be
forall be.
InaccessibleQAssignment be
-> InaccessibleQAssignment be -> InaccessibleQAssignment be
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall be b.
Integral b =>
b -> InaccessibleQAssignment be -> InaccessibleQAssignment be
stimes :: forall b.
Integral b =>
b -> InaccessibleQAssignment be -> InaccessibleQAssignment be
$cstimes :: forall be b.
Integral b =>
b -> InaccessibleQAssignment be -> InaccessibleQAssignment be
sconcat :: NonEmpty (InaccessibleQAssignment be) -> InaccessibleQAssignment be
$csconcat :: forall be.
NonEmpty (InaccessibleQAssignment be) -> InaccessibleQAssignment be
<> :: InaccessibleQAssignment be
-> InaccessibleQAssignment be -> InaccessibleQAssignment be
$c<> :: forall be.
InaccessibleQAssignment be
-> InaccessibleQAssignment be -> InaccessibleQAssignment be
Data.Semigroup.Semigroup, InaccessibleQAssignment be
[InaccessibleQAssignment be] -> InaccessibleQAssignment be
InaccessibleQAssignment be
-> InaccessibleQAssignment be -> InaccessibleQAssignment be
forall be. Semigroup (InaccessibleQAssignment be)
forall be. InaccessibleQAssignment be
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall be.
[InaccessibleQAssignment be] -> InaccessibleQAssignment be
forall be.
InaccessibleQAssignment be
-> InaccessibleQAssignment be -> InaccessibleQAssignment be
mconcat :: [InaccessibleQAssignment be] -> InaccessibleQAssignment be
$cmconcat :: forall be.
[InaccessibleQAssignment be] -> InaccessibleQAssignment be
mappend :: InaccessibleQAssignment be
-> InaccessibleQAssignment be -> InaccessibleQAssignment be
$cmappend :: forall be.
InaccessibleQAssignment be
-> InaccessibleQAssignment be -> InaccessibleQAssignment be
mempty :: InaccessibleQAssignment be
$cmempty :: forall be. InaccessibleQAssignment be
Monoid)
onConflictUpdateInstead
:: forall be table proj
. ( BeamHasInsertOnConflict be
, Beamable table
, ProjectibleWithPredicate AnyType () (InaccessibleQAssignment be) proj
)
=> (table (Const (InaccessibleQAssignment be)) -> proj)
-> SqlConflictAction be table
onConflictUpdateInstead :: forall be (table :: (* -> *) -> *) proj.
(BeamHasInsertOnConflict be, Beamable table,
ProjectibleWithPredicate
AnyType () (InaccessibleQAssignment be) proj) =>
(table (Const (InaccessibleQAssignment be)) -> proj)
-> SqlConflictAction be table
onConflictUpdateInstead table (Const (InaccessibleQAssignment be)) -> proj
mkProj = forall be (table :: (* -> *) -> *).
(BeamHasInsertOnConflict be, Beamable table) =>
(forall s.
table (QField s) -> table (QExpr be s) -> QAssignment be s)
-> SqlConflictAction be table
onConflictUpdateSet forall s.
table (QField s) -> table (QExpr be s) -> QAssignment be s
mkAssignments
where
mkAssignments
:: forall s
. table (QField s)
-> table (QExpr be s)
-> QAssignment be s
mkAssignments :: forall s.
table (QField s) -> table (QExpr be s) -> QAssignment be s
mkAssignments table (QField s)
table table (QExpr be s)
excluded = forall be s.
[(BeamSqlBackendFieldNameSyntax be,
BeamSqlBackendExpressionSyntax be)]
-> QAssignment be s
QAssignment forall a b. (a -> b) -> a -> b
$ forall be.
InaccessibleQAssignment be
-> [(BeamSqlBackendFieldNameSyntax be,
BeamSqlBackendExpressionSyntax be)]
unInaccessibleQAssignment forall a b. (a -> b) -> a -> b
$
forall w a. Writer w a -> w
Strict.execWriter forall a b. (a -> b) -> a -> b
$ forall (contextPredicate :: * -> Constraint) be res a
(m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project'
(forall {k} (t :: k). Proxy t
Proxy @AnyType)
(forall {k} (t :: k). Proxy t
Proxy @((), InaccessibleQAssignment be))
(\Proxy context
_ Proxy ()
_ InaccessibleQAssignment be
a -> forall w (m :: * -> *). MonadWriter w m => w -> m ()
Strict.tell InaccessibleQAssignment be
a forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return InaccessibleQAssignment be
a)
(table (Const (InaccessibleQAssignment be)) -> proj
mkProj forall a b. (a -> b) -> a -> b
$ forall a. Identity a -> a
runIdentity forall a b. (a -> b) -> a -> b
$ forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
(g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM forall s a.
Columnar' (QField s) a
-> Columnar' (QExpr be s) a
-> Identity (Columnar' (Const (InaccessibleQAssignment be)) a)
mkAssignment table (QField s)
table table (QExpr be s)
excluded)
mkAssignment
:: forall s a
. Columnar' (QField s) a
-> Columnar' (QExpr be s) a
-> Identity (Columnar' (Const (InaccessibleQAssignment be)) a)
mkAssignment :: forall s a.
Columnar' (QField s) a
-> Columnar' (QExpr be s) a
-> Identity (Columnar' (Const (InaccessibleQAssignment be)) a)
mkAssignment (Columnar' Columnar (QField s) a
field) (Columnar' Columnar (QExpr be s) a
value) =
forall a. a -> Identity a
Identity forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall a b. (a -> b) -> a -> b
$ forall {k} a (b :: k). a -> Const a b
Const forall a b. (a -> b) -> a -> b
$
forall be.
[(BeamSqlBackendFieldNameSyntax be,
BeamSqlBackendExpressionSyntax be)]
-> InaccessibleQAssignment be
InaccessibleQAssignment forall a b. (a -> b) -> a -> b
$ forall be s.
QAssignment be s
-> [(BeamSqlBackendFieldNameSyntax be,
BeamSqlBackendExpressionSyntax be)]
unQAssignment forall a b. (a -> b) -> a -> b
$ Columnar (QField s) a
field forall be s lhs rhs.
SqlUpdatable be s lhs rhs =>
lhs -> rhs -> QAssignment be s
<-. Columnar (QExpr be s) a
value
onConflictUpdateAll
:: forall be table
. ( BeamHasInsertOnConflict be
, Beamable table
)
=> SqlConflictAction be table
onConflictUpdateAll :: forall be (table :: (* -> *) -> *).
(BeamHasInsertOnConflict be, Beamable table) =>
SqlConflictAction be table
onConflictUpdateAll = forall be (table :: (* -> *) -> *) proj.
(BeamHasInsertOnConflict be, Beamable table,
ProjectibleWithPredicate
AnyType () (InaccessibleQAssignment be) proj) =>
(table (Const (InaccessibleQAssignment be)) -> proj)
-> SqlConflictAction be table
onConflictUpdateInstead forall a. a -> a
id