From 6ac8d5e64f9131bfbb5370354d34b7cffedfa1d4 Mon Sep 17 00:00:00 2001 From: Johannes Riemenschneider Date: Mon, 23 Feb 2026 17:21:17 +0100 Subject: [PATCH] updated documentation of delete - adhered to PR comment --- .../references/sqlreference/statements/delete.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/content/references/sqlreference/statements/delete.md b/content/references/sqlreference/statements/delete.md index beffb7f..e4328cc 100644 --- a/content/references/sqlreference/statements/delete.md +++ b/content/references/sqlreference/statements/delete.md @@ -29,7 +29,19 @@ corresponding channel information. ```sql delete from pending_notifications n using channels c -where n.reciever_id = $1 +where n.receiver_id = $1 and n.channel_id = c.id returning *; ``` + +Scans in the returning clause read the database after the delete is completed. +That is why the exists statement in the returning clause does not match the deleted row with itself in the following example. +```sql +delete from users +where users.user_id = 42 +returning users.user_id, exists (select * from users where users.user_id=42); + +user_id | ?column? +--------+---------- + 42 | f +```