Apply render_cell plugin hook to primary key columns#2652
Open
westurner wants to merge 1 commit intosimonw:mainfrom
Open
Apply render_cell plugin hook to primary key columns#2652westurner wants to merge 1 commit intosimonw:mainfrom
render_cell plugin hook to primary key columns#2652westurner wants to merge 1 commit intosimonw:mainfrom
Conversation
This update modifies the table view to execute the `render_cell` plugin hook against simple (single) primary key (or "Link") columns. Instead of always generating a default HTML anchor link pointing to the row view, Datasette now checks if any plugin returns a custom display value. If a custom rendering is provided, it is used; otherwise, it safely falls back to the default `<a href="...">` behavior. Key Changes & Optimizations: - Feature: Executes `render_cell` hooks for simple primary keys in `display_columns_and_rows`, safely resolving `pk_value` from the row. - Performance: Pre-computes `has_single_pk`, `pk_index`, and `has_render_cell_hooks` outside of the O(N) row loop to eliminate redundant operations. - Performance: Completely skips hook evaluation if no plugins are registered to listen to `render_cell`. - Refactor: Streamlines row cell appending by using an inline `A if A is not None else B` fallback, which prevents duplicate dictionary initializations and safely handles intentional empty strings (`""`) returned by plugins. - Compatibility: Passes `pks=pks_for_display` to the hook call to satisfy upstream API requirements. Assisted By: Gemini 3.1 Pro
Author
|
From https://github.com/pulp for example:
So I added "Assisted By:". I would say this one was more of a pair coding with LLMs than a vibe coding. I ran the tests a number of times locally. I'm not sure why I have 15 local test failures before and after this PR. Does the Actions build run the tests with coverage? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This update modifies the table view to execute the
render_cellplugin hook against simple (single) primary key (or "Link") columns. Instead of always generating a default HTML anchor link pointing to the row view, Datasette now checks if any plugin returns a custom display value. If a custom rendering is provided, it is used; otherwise, it safely falls back to the default<a href="...">behavior.Key Changes & Optimizations:
render_cellhooks for simple primary keys indisplay_columns_and_rows, safely resolvingpk_valuefrom the row.has_single_pk,pk_index, andhas_render_cell_hooksoutside of the O(N) row loop to eliminate redundant operations.render_cell.A if A is not None else Bfallback, which prevents duplicate dictionary initializations and safely handles intentional empty strings ("") returned by plugins.pks=pks_for_displayto the hook call to satisfy upstream API requirements.Assisted By: Gemini 3.1 Pro
📚 Documentation preview 📚: https://datasette--2652.org.readthedocs.build/en/2652/