sqlite-html icon indicating copy to clipboard operation
sqlite-html copied to clipboard

Add "path" column to `html_each`

Open asg017 opened this issue 3 years ago • 0 comments

Similar to the fullkey / path columns in json_each/json_tree.

sqlite> select fullkey, path, key, value from json_tree('{"sub": {"name": "alex"}}');
┌────────────┬───────┬──────┬─────────────────────────┐
│  fullkey   │ path  │ key  │          value          │
├────────────┼───────┼──────┼─────────────────────────┤
│ $          │ $     │      │ {"sub":{"name":"alex"}} │
│ $.sub      │ $     │ sub  │ {"name":"alex"}         │
│ $.sub.name │ $.sub │ name │ alex                    │
└────────────┴───────┴──────┴─────────────────────────┘

But instead, it's a CSS selector to the exact HTML Element, similar to the "copy path" button in Chrome Devtools.

image

The catch: this is pretty difficult to calculate, here's Chrome's implementation of it. https://github.com/ChromeDevTools/devtools-frontend/blob/69ed2407734d98fdbaaabaac91fb679ca73bd88c/front_end/panels/elements/DOMPath.ts#L73-L171

asg017 avatar Aug 01 '22 17:08 asg017