html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,issue,performed_via_github_app
https://github.com/simonw/datasette/issues/1863#issuecomment-1320563197,https://api.github.com/repos/simonw/datasette/issues/1863,1320563197,IC_kwDOBm6k_c5OtjH9,9599,2022-11-18T21:47:35Z,2022-11-18T21:48:07Z,OWNER,"Incomplete implementation of this view:
```python
class RowUpdateView(BaseView):
name = ""row-update""
def __init__(self, datasette):
self.ds = datasette
async def post(self, request):
database_route = tilde_decode(request.url_vars[""database""])
table = tilde_decode(request.url_vars[""table""])
try:
db = self.ds.get_database(route=database_route)
except KeyError:
return _error([""Database not found: {}"".format(database_route)], 404)
database_name = db.name
if not await db.table_exists(table):
return _error([""Table not found: {}"".format(table)], 404)
pk_values = urlsafe_components(request.url_vars[""pks""])
sql, params, pks = await row_sql_params_pks(db, table, pk_values)
results = await db.execute(sql, params, truncate=True)
rows = list(results.rows)
if not rows:
return _error([f""Record not found: {pk_values}""], 404)
# Ensure user has permission to update this row
if not await self.ds.permission_allowed(
request.actor, ""update-row"", resource=(database_name, table)
):
return _error([""Permission denied""], 403)
body = await request.post_body()
try:
data = json.loads(body)
except json.JSONDecodeError as e:
return _error([""Invalid JSON: {}"".format(e)])
if not isinstance(data, dict):
return _error([""JSON must be a dictionary""])
def update_row(conn):
sqlite_utils.Database(conn)[table].update(pk_values, updates)
await db.execute_write_fn(update_row)
result = {""ok"": True}
if data.get(""return""):
result[""row""] = {""row-here"": ""TODO""}
return Response.json(result, status=200)
```
This is before the refactor in:
- #1896","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",1425029242,