mirror of
https://github.com/simonw/datasette.git
synced 2026-05-27 12:34:37 +02:00
Only return render_coll columns that differ from default, refs #2619
This commit is contained in:
parent
eae94dc2c3
commit
6fede23a2e
4 changed files with 7 additions and 11 deletions
|
|
@ -140,9 +140,6 @@ class RowView(DataView):
|
|||
break
|
||||
if plugin_display_value:
|
||||
rendered_row[column] = str(plugin_display_value)
|
||||
else:
|
||||
# Default: convert value to string
|
||||
rendered_row[column] = "" if value is None else str(value)
|
||||
rendered_rows.append(rendered_row)
|
||||
data["render_cell"] = rendered_rows
|
||||
|
||||
|
|
|
|||
|
|
@ -1516,9 +1516,6 @@ async def table_view_data(
|
|||
break
|
||||
if plugin_display_value:
|
||||
rendered_row[column] = str(plugin_display_value)
|
||||
else:
|
||||
# Default: convert value to string
|
||||
rendered_row[column] = "" if value is None else str(value)
|
||||
rendered_rows.append(rendered_row)
|
||||
return rendered_rows
|
||||
|
||||
|
|
|
|||
|
|
@ -792,14 +792,15 @@ async def test_row_extra_render_cell():
|
|||
assert "rows" in data
|
||||
|
||||
# render_cell should be a list with one row (since this is a row page)
|
||||
# Only columns modified by plugins are included (sparse output)
|
||||
render_cell = data["render_cell"]
|
||||
assert len(render_cell) == 1
|
||||
|
||||
# The row: id=1, name='Alice'
|
||||
# The 'name' column should be rendered by our plugin as <strong>Alice</strong>
|
||||
assert render_cell[0]["name"] == "<strong>Alice</strong>"
|
||||
# The 'id' column should use default rendering (just the value as string)
|
||||
assert render_cell[0]["id"] == "1"
|
||||
# The 'id' column is not included since no plugin modified it
|
||||
assert "id" not in render_cell[0]
|
||||
|
||||
# The regular rows should still contain raw values
|
||||
assert data["rows"] == [{"id": 1, "name": "Alice"}]
|
||||
|
|
|
|||
|
|
@ -1426,18 +1426,19 @@ async def test_extra_render_cell():
|
|||
assert "rows" in data
|
||||
|
||||
# render_cell should be a list of rows, each row being a dict of column -> rendered HTML
|
||||
# Only columns modified by plugins are included (sparse output)
|
||||
render_cell = data["render_cell"]
|
||||
assert len(render_cell) == 2
|
||||
|
||||
# First row: id=1, name='Alice'
|
||||
# The 'name' column should be rendered by our plugin as <strong>Alice</strong>
|
||||
assert render_cell[0]["name"] == "<strong>Alice</strong>"
|
||||
# The 'id' column should use default rendering (just the value as string)
|
||||
assert render_cell[0]["id"] == "1"
|
||||
# The 'id' column is not included since no plugin modified it
|
||||
assert "id" not in render_cell[0]
|
||||
|
||||
# Second row: id=2, name='Bob'
|
||||
assert render_cell[1]["name"] == "<strong>Bob</strong>"
|
||||
assert render_cell[1]["id"] == "2"
|
||||
assert "id" not in render_cell[1]
|
||||
|
||||
# The regular rows should still contain raw values
|
||||
assert data["rows"] == [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue