From: Matt S Trout Date: Mon, 30 Sep 2019 20:05:43 +0000 (+0000) Subject: document delete query X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ef42b9a699e2dc37e13870b0f7f5db38cd907c71;p=scpubgit%2FQ-Branch.git document delete query --- diff --git a/lib/SQL/Abstract/Reference.pm b/lib/SQL/Abstract/Reference.pm index 44ad71c..fd29f33 100644 --- a/lib/SQL/Abstract/Reference.pm +++ b/lib/SQL/Abstract/Reference.pm @@ -989,9 +989,6 @@ an order by direction: An insert node accepts an into/target clause, a fields clause, a values/from clause, and a returning clause. -Note that there is no clause named insert since into or values could be -what the user meant by that, and it turned out to just be confusing. - The target clause is expanded with an ident default. The fields clause is expanded as a list expression if an arrayref, and @@ -1096,4 +1093,34 @@ The returning clause is expanded as a list expr with an ident default. UPDATE foo SET bar = ?, baz = baz + ? WHERE (NOT quux) RETURNING id, baz [ 3, 1 ] +=head2 delete + +delete accepts from/target, where, and returning clauses. + +The target clause is expanded with an ident default. + +The where clauses is expanded as a normal expr. + +The returning clause is expanded as a list expr with an ident default. + + # expr + { -delete => { + from => 'foo', + returning => 'id', + where => { bar => { '<' => 10 } }, + } } + + # aqt + { -delete => { + returning => { -op => [ ',', { -ident => [ 'id' ] } ] }, + target => { -op => [ ',', { -ident => [ 'foo' ] } ] }, + where => { -op => + [ '<', { -ident => [ 'bar' ] }, { -bind => [ 'bar', 10 ] } ] + }, + } } + + # query + DELETE FROM foo WHERE bar < ? RETURNING id + [ 10 ] + =cut