From 307692c325ee7abc023d77425bfc524c76fdf1e9 Mon Sep 17 00:00:00 2001 From: Steve Chavez Date: Wed, 12 Feb 2025 14:48:08 -0500 Subject: [PATCH] break: remove limited updated/delete feature (#3907) BREAKING CHANGE As agreed on https://github.com/PostgREST/postgrest/issues/3013#issuecomment-1770186262, this removes the limited update/delete feature. The feature was complicated, largely unused and caused other bugs in mutations. It was added in #2195 and #2211. --- CHANGELOG.md | 2 + docs/references/api/tables_views.rst | 25 -- docs/references/errors.rst | 8 - postgrest.cabal | 1 - src/PostgREST/ApiRequest.hs | 3 +- src/PostgREST/ApiRequest/Types.hs | 2 - src/PostgREST/Error.hs | 17 +- src/PostgREST/Plan.hs | 5 +- src/PostgREST/Plan/MutatePlan.hs | 8 +- src/PostgREST/Query.hs | 16 +- src/PostgREST/Query/QueryBuilder.hs | 50 +-- src/PostgREST/Query/SqlFragment.hs | 8 - src/PostgREST/SchemaCache/Table.hs | 2 +- .../spec/Feature/Query/LimitedMutationSpec.hs | 305 ------------------ test/spec/Feature/Query/UpdateSpec.hs | 12 - test/spec/Main.hs | 4 - test/spec/SpecHelper.hs | 33 -- test/spec/fixtures/data.sql | 18 -- test/spec/fixtures/schema.sql | 50 --- 19 files changed, 20 insertions(+), 549 deletions(-) delete mode 100644 test/spec/Feature/Query/LimitedMutationSpec.hs diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0e7d050..56f318a67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Previously, this would silently return 200 - OK on the root endpoint, but don't provide any usable endpoints. - #3757, Remove support for `Prefer: params=single-object` - @joelonsql + This preference was deprecated in favor of Functions with an array of JSON objects + - #3013, Drop support for Limited updates/deletes + + The feature was complicated and largely unused. ## [12.2.8] - 2025-02-10 diff --git a/docs/references/api/tables_views.rst b/docs/references/api/tables_views.rst index 9b433cee8..3ea045c74 100644 --- a/docs/references/api/tables_views.rst +++ b/docs/references/api/tables_views.rst @@ -730,31 +730,6 @@ Deletions also support :ref:`prefer_return`, :ref:`resource_embedding` and :ref: Beware of accidentally deleting all rows in a table. To learn to prevent that see :ref:`block_fulltable`. -.. _limited_update_delete: - -Limited Update/Delete -===================== - -You can limit the amount of affected rows by :ref:`update` or :ref:`delete` with the ``limit`` query parameter. For this, you must add an explicit ``order`` on a unique column(s). - -.. code-block:: bash - - curl -X PATCH "/users?limit=10&order=id&last_login=lt.2020-01-01" \ - -H "Content-Type: application/json" \ - -d '{ "status": "inactive" }' - -.. code-block:: bash - - curl -X DELETE "http://localhost:3000/users?limit=10&order=id&status=eq.inactive" - -If your table has no unique columns, you can use the `ctid `_ system column. - -Using ``offset`` to target a different subset of rows is also possible. - -.. note:: - - There is no native ``UPDATE...LIMIT`` or ``DELETE...LIMIT`` support in PostgreSQL; the generated query simulates that behavior and is based on `this Crunchy Data blog post `_. - .. raw:: html