technohiker / obsidian-multi-properties

Plugin for Obsidian that allows user to add properties to multiple notes at once.
MIT License
93 stars 0 forks source link

Bug: Adding existing value to text-property formats property as list #25

Open Solanaar opened 1 month ago

Solanaar commented 1 month ago

Issue: When you add a value to a property of type text and that is the only value, it formats it as if the property type is list, leading to a type missmatch warning.

Reproduction:

  1. Create a new note
  2. add a text property (e.g. location)
  3. add a value (e.g. earth)

if done correctly, it should look like this:

location: earth

  1. right click on the folder and run the "Add props to folder's notes" command
  2. put in the property name and the value, type should stay as "Text" and submit

Result: The property will be reformatted to a list, while the property type will stay as text, which results in a type missmatch exception. Example:

location:

Workaround: Option A: Before adding the value, change the property-type to list. Option B: Before adding the value, first remove the property from all notes in that folder.

Both workarounds have their shortcomings. Option A will add additional lines to the frontmatter, making it less readable and potentially leading to conflicts if the property is used in other folders, while option B could potentially lead to loss of data, if some notes in that folder contain a different value for that property.

Use case/Relevancy: When adding a property with only one value to all notes in a folder, while some already have that property and value. For example when you have a TTRPG vault with a folder named "people" and a property named "type", that would have values like "people, location, item, etc.", usually every note would only have one value, so a list wouldn't be necessary.

I hope this hasn't been reported yet and I could provide a clear report.

technohiker commented 1 month ago

Sounds like you have the "Overwrite existing text" setting disabled. When that's the case, any new text properties will automatically be combined and appended to a list. When Overwrite is enabled, then the text property will remain as text.

I hadn't foreseen the possibility of the exact same value being added and merged, leading to a single text value being read as a list. I should be able to create a check for whether the values are the same.

technohiker commented 1 month ago

This should be fixed in the 1.1.2 release.