datasette/tests/plugins
August Cayzer a759c47c9e Return MultiParams from request.post_vars() to preserve multi-valued form fields
Form submissions with multiple values for the same key (e.g. ``<select
multiple>``) previously had every value but the last silently discarded,
because ``post_vars()`` called ``dict(parse_qsl(...))``. Switch the
implementation to return a ``MultiParams`` object built from
``parse_qs(...)``, mirroring the existing ``request.args`` shape so both
sides of the GET/POST surface behave consistently.

``MultiParams`` gains an ``items()`` method that yields (key, first_value)
pairs, matching ``__getitem__`` semantics, so it works in patterns such as
``dict(post_vars())`` and the existing ``_coerce_execute_write_payload``
dict comprehension.

Internal callers of ``_json_or_form_payload`` (``execute_write`` and
``stored_queries``) had ``isinstance(data, dict)`` guards intended to
validate JSON shape but also rejected the new ``MultiParams`` return on
the form path. Gate those guards on ``is_json`` so the form path passes
through unchanged.

The bundled ``my_plugin`` test fixture wraps ``post_vars()`` in ``dict()``
before passing to ``Response.json``, demonstrating the migration path for
plugins that need a JSON-serialisable mapping.

Closes #2425
2026-05-29 21:43:39 +01:00
..
messages_output_renderer.py Flash messages mechanism, closes #790 2020-06-02 14:12:18 -07:00
my_plugin.py Return MultiParams from request.post_vars() to preserve multi-valued form fields 2026-05-29 21:43:39 +01:00
my_plugin_2.py Clean up query management test coverage 2026-05-24 23:06:01 -07:00
register_output_renderer.py register_output_renderer can now return Response, closes #953 2020-08-27 21:02:50 -07:00
sleep_sql_function.py Remove undocumented sqlite_functions mechanism, closes #1567 2021-12-17 17:54:39 -08:00
view_name.py Refactored test plugins into tests/plugins, closes #775 2020-05-27 17:57:25 -07:00