-
Notifications
You must be signed in to change notification settings - Fork 184
Open
Labels
breaking changeChange will require a major version bumpChange will require a major version bumpenhancement
Milestone
Description
Currently we have:
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]
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]
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]The limitation of these is that they all return the full rows, while one might only want a subset of the rows.
For this reason, the Postgres backend provides the additional functions runPg...ReturningList functions, where we see type signatures such as:
deleteReturning :: Projectible Postgres a
=> DatabaseEntity Postgres be (TableEntity table)
-> (forall s. table (QExpr Postgres s) -> QExpr Postgres s Bool)
-> (table (QExpr Postgres PostgresInaccessible) -> a)
-> PgDeleteReturning (QExprToIdentity a)The key difference is that instead of returning table Identity, we pass in a projection function, of type (table (QExpr Postgres PostgresInaccessible) -> a), and we use it to project out the fields we want to return (instead of returning the whole row). So we're replacing table Identity with QExprToIdentity a, where a is the chosen row type to project out.
Given that the SQLite backend supports this feature as well, it seems natural to generalise these monads.
Metadata
Metadata
Assignees
Labels
breaking changeChange will require a major version bumpChange will require a major version bumpenhancement