Copyright | (c) Eitan Chatav 2019 |
---|---|
Maintainer | eitan@morphism.tech |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
delete statements
Synopsis
- deleteFrom :: (SListI row, Has sch db schema, Has tab0 schema ('Table table)) => Aliased (QualifiedAlias sch) (tab ::: tab0) -> UsingClause with db params from -> Condition 'Ungrouped '[] with db params ((tab ::: TableToRow table) ': from) -> ReturningClause with db params ((tab ::: TableToRow table) ': from) row -> Manipulation with db params row
- deleteFrom_ :: (Has sch db schema, Has tab0 schema ('Table table)) => Aliased (QualifiedAlias sch) (tab ::: tab0) -> Condition 'Ungrouped '[] with db params '[tab ::: TableToRow table] -> Manipulation with db params '[]
Delete
:: (SListI row, Has sch db schema, Has tab0 schema ('Table table)) | |
=> Aliased (QualifiedAlias sch) (tab ::: tab0) | table to delete from |
-> UsingClause with db params from | |
-> Condition 'Ungrouped '[] with db params ((tab ::: TableToRow table) ': from) | condition under which to delete a row |
-> ReturningClause with db params ((tab ::: TableToRow table) ': from) row | results to return |
-> Manipulation with db params row |
Delete rows from a table.
>>>
type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]
>>>
type Schema = '["tab1" ::: 'Table ('[] :=> Columns), "tab2" ::: 'Table ('[] :=> Columns)]
>>>
:{
let manp :: Manipulation with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] manp = deleteFrom #tab1 (Using (table #tab2)) (#tab1 ! #col1 .== #tab2 ! #col2) (Returning (#tab1 & DotStar)) in printSQL manp :} DELETE FROM "tab1" AS "tab1" USING "tab2" AS "tab2" WHERE ("tab1"."col1" = "tab2"."col2") RETURNING "tab1".*
:: (Has sch db schema, Has tab0 schema ('Table table)) | |
=> Aliased (QualifiedAlias sch) (tab ::: tab0) | table to delete from |
-> Condition 'Ungrouped '[] with db params '[tab ::: TableToRow table] | condition under which to delete a row |
-> Manipulation with db params '[] |
Delete rows returning Nil
.
>>>
type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4]
>>>
type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>>
:{
let manp :: Manipulation with (Public Schema) '[ 'NotNull 'PGint4] '[] manp = deleteFrom_ (#tab `as` #t) (#t ! #col1 .== param @1) in printSQL manp :} DELETE FROM "tab" AS "t" WHERE ("t"."col1" = ($1 :: int4))