From 2b06da29a16779ce54b2a57e79a9a2adb47ffcce Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 18 Mar 2026 12:18:48 -0700 Subject: [PATCH] Rename set-column-types action to et-column-type Refs https://github.com/simonw/datasette/pull/2674#issuecomment-4085015792 --- datasette/default_actions.py | 4 ++-- datasette/views/table.py | 2 +- docs/authentication.rst | 14 ++++++-------- docs/json_api.rst | 2 +- tests/test_auth.py | 8 ++++---- tests/test_internals_datasette.py | 2 +- tests/test_permissions.py | 6 +++--- 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/datasette/default_actions.py b/datasette/default_actions.py index 216d0046..149a4e5f 100644 --- a/datasette/default_actions.py +++ b/datasette/default_actions.py @@ -86,9 +86,9 @@ def register_actions(): resource_class=TableResource, ), Action( - name="set-column-types", + name="set-column-type", abbr="sct", - description="Set column types", + description="Set column type", resource_class=TableResource, ), Action( diff --git a/datasette/views/table.py b/datasette/views/table.py index a6b13918..e7a226af 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -682,7 +682,7 @@ class TableSetColumnTypeView(BaseView): table_name = resolved.table if not await self.ds.allowed( - action="set-column-types", + action="set-column-type", resource=TableResource(database=database_name, table=table_name), actor=request.actor, ): diff --git a/docs/authentication.rst b/docs/authentication.rst index 90fd26ce..951a65ec 100644 --- a/docs/authentication.rst +++ b/docs/authentication.rst @@ -33,7 +33,7 @@ The one exception is the "root" account, which you can sign into while using Dat The ``--root`` flag is designed for local development and testing. When you start Datasette with ``--root``, the root user automatically receives every permission, including: * All view permissions (``view-instance``, ``view-database``, ``view-table``, etc.) -* All write permissions (``insert-row``, ``update-row``, ``delete-row``, ``create-table``, ``alter-table``, ``set-column-types``, ``drop-table``) +* All write permissions (``insert-row``, ``update-row``, ``delete-row``, ``create-table``, ``alter-table``, ``set-column-type``, ``drop-table``) * Debug permissions (``permissions-debug``, ``debug-menu``) * Any custom permissions defined by plugins @@ -886,7 +886,7 @@ To grant ``create-table`` to the user with ``id`` of ``editor`` for the ``docs`` } .. [[[end]]] -Other table-scoped write permissions, including ``set-column-types``, can be configured in the same place. +Other table-scoped write permissions, including ``set-column-type``, can be configured in the same place. And for ``insert-row`` against the ``reports`` table in that ``docs`` database: @@ -1212,9 +1212,7 @@ To include an expiry pass ``expire_after=`` to ``datasette.set_actor_cookie()`` .. code-block:: python response = Response.redirect("/") - datasette.set_actor_cookie( - response, {"id": "cleopaws"}, expire_after=60 * 60 * 24 - ) + datasette.set_actor_cookie(response, {"id": "cleopaws"}, expire_after=60 * 60 * 24) The resulting cookie will encode data that looks something like this: @@ -1350,10 +1348,10 @@ Actor is allowed to alter a database table. ``table`` is the name of the table (string) -.. _actions_set_column_types: +.. _actions_set_column_type: -set-column-types ----------------- +set-column-type +--------------- Actor is allowed to set assigned column types for columns in a table. diff --git a/docs/json_api.rst b/docs/json_api.rst index 7a48a26e..48c70af6 100644 --- a/docs/json_api.rst +++ b/docs/json_api.rst @@ -946,7 +946,7 @@ Pass ``"alter": true`` to automatically add any missing columns to the existing Setting a column type ~~~~~~~~~~~~~~~~~~~~~ -To set a column type for a table column, make a ``POST`` to ``///-/set-column-type``. This requires the :ref:`actions_set_column_types` permission. +To set a column type for a table column, make a ``POST`` to ``//
/-/set-column-type``. This requires the :ref:`actions_set_column_type` permission. :: diff --git a/tests/test_auth.py b/tests/test_auth.py index cb77c7a2..5868a21c 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -191,7 +191,7 @@ def test_auth_create_token( "all:view-query", "database:fixtures:drop-table", "resource:fixtures:foreign_key_references:insert-row", - "resource:fixtures:facetable:set-column-types", + "resource:fixtures:facetable:set-column-type", } ) # Now try actually creating one @@ -430,7 +430,7 @@ async def test_root_with_root_enabled_gets_all_permissions(ds_client): assert ( await ds_client.ds.allowed( - action="set-column-types", + action="set-column-type", resource=TableResource("fixtures", "facetable"), actor=root_actor, ) @@ -504,9 +504,9 @@ async def test_root_without_root_enabled_no_special_permissions(ds_client): assert ( await ds_client.ds.allowed( - action="set-column-types", + action="set-column-type", resource=TableResource("fixtures", "facetable"), actor=root_actor, ) is not True - ), "Root without root_enabled should not automatically get set-column-types" + ), "Root without root_enabled should not automatically get set-column-type" diff --git a/tests/test_internals_datasette.py b/tests/test_internals_datasette.py index 008fa7cd..ec0180a7 100644 --- a/tests/test_internals_datasette.py +++ b/tests/test_internals_datasette.py @@ -170,7 +170,7 @@ async def test_get_action(ds_client): "vt", "view-table", "sct", - "set-column-types", + "set-column-type", ): action = ds.get_action(name_or_abbr) if "-" in name_or_abbr: diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 4db89a0e..f9303759 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -831,19 +831,19 @@ PermConfigTestCase = collections.namedtuple( resource=("perms_ds_one", "t1"), expected_result=True, ), - # set-column-types on specific table + # set-column-type on specific table PermConfigTestCase( config={ "databases": { "perms_ds_one": { "tables": { - "t1": {"permissions": {"set-column-types": {"id": "user"}}} + "t1": {"permissions": {"set-column-type": {"id": "user"}}} } } } }, actor={"id": "user"}, - action="set-column-types", + action="set-column-type", resource=("perms_ds_one", "t1"), expected_result=True, ),