Fix for MagicParameters error with no POST body, closes #967

This commit is contained in:
Simon Willison 2020-09-15 13:10:25 -07:00
commit 448d13ea6b
2 changed files with 41 additions and 1 deletions

View file

@ -371,6 +371,11 @@ class MagicParameters(dict):
)
)
def __len__(self):
# Workaround for 'Incorrect number of bindings' error
# https://github.com/simonw/datasette/issues/967#issuecomment-692951144
return super().__len__() or 1
def __getitem__(self, key):
if key.startswith("_") and key.count("_") >= 2:
prefix, suffix = key[1:].split("_", 1)