simonw / simonw/datasette

render_cell plugin hook's row object is not a sqlite.Row

Open
#1,973 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug documentation plugins
Dominant language
Python
Stars
11.5k
Forks
904
Avg merge
4d 17h
Merged PRs (30d)
18

Description

From https://docs.datasette.io/en/stable/plugin_hooks.html#render-cell-row-value-column-table-database-datasette:

row - sqlite.Row
The SQLite row object that the value being rendered is part of

This appears to actually be a CustomRow, but I think that's unrelated to my issue.

I have a table:

CREATE TABLE IF NOT EXISTS "dss_job_stats"(
  job_id integer not null references dss_job(id) on delete cascade,
  host text not null,
  // other columns elided as irrelevant
  primary key (job_id, host)
);

On datasette 0.63.2, the render_cell hook receives a row value that looks like:

CustomRow([('job_id', {'value': 2, 'label': '2'}), ('host', 'cldellow.com')])

I expected the job_id value to be 2, but it's actually {'value': 2, 'label': '2'}.

I can work around this, but was wondering if this was intended behaviour?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the render_cell hook documentation and datasette/utils/init.py, especially the CustomRow implementation linked in the issue. Reproduce the hook with the shown dss_job_stats schema and inspect the row received by the plugin. Done means determining whether the documented sqlite.Row contract or the observed value shape is intended, then recording the agreed behavior in the relevant test or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlite
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.