mirror of
https://github.com/simonw/datasette.git
synced 2026-06-14 13:06:58 +02:00
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 |
||
|---|---|---|
| .. | ||
| messages_output_renderer.py | ||
| my_plugin.py | ||
| my_plugin_2.py | ||
| register_output_renderer.py | ||
| sleep_sql_function.py | ||
| view_name.py | ||