Perhaps prohibitively expensive at Moby Dick scale, but I wonder what might be the most efficient way to detect inadvertent duplicates when a user changes a row id, either with the Bike Markdown {#identifier} syntax, or by updating the API value of Row.id ?
( When we import MD, any {#identifier .class .class key=value key=value} elements are absorbed into the Bike data structure, but aren’t immediately visible – without special styling or outline path filtering – and we can accidentally create link target puzzles when a non-unique id value is specified in a document )
Bike’s outline structure is dictionary[Row.ID, Row]. So at least id testing performance is rarely an issue.
This shouldn’t be possible. It should be that ID’s are readonly/immutable at runtime. And it should be that if the source document (ie .md, .bike, etc) has duplicate ID’s then they are deduplicated (duplicates replaced with new generated ID) on load.
You shouldn’t be able to set custom ID’s on existing rows. Instead the pattern you can use if you want a custom id (for example Calendar extension does this) is something along the lines of firsts outline.getRowById and if that return undefined then you can insert a row with that ID and be confident that the ID will be accepted.
If you really want to be sure of the ID’s that are used when you insert rows you can read the final ID’s from the resulting rows returned by outline.insertRows.
I think this isn’t true, if the #identifier already exists then the imported row will be assigned a different identifier. Hopefully that’s true, let me know if you are seeing something different!
If you really do want to set an id on an existing row I think the path is:
Remove the target row
Ensure desired ID doesn’t already exist
Insert a new row with all the same properties as target, except with desired ID
Hope that all makes some sense. Questions welcome!