RafaelGB / obsidian-db-folder

Obsidian Plugin to Allow Notion like database based on folders
MIT License
1.25k stars 61 forks source link

[BUG] Unrelated frontmatter being modified when modifying via table #117

Closed PaperOrb closed 2 years ago

PaperOrb commented 2 years ago

Selecting a personalRating: folder_db_button_click

Causes modifications to unrelated fields inside the note which breaks things: folder_db_diff folder_db_2

Here's the settings for that personalRating column: column_settings

Using Ubuntu 21.04 with obsidian 0.14.15

RafaelGB commented 2 years ago

hi @PaperOrb After edit a cell, the plugin check every field inside the frontmatter and adds commas wrapping the text if it’s necessary.

In your image, those fields than lose their commas looks like they do not need it but url field cause it contains “:”

Could you attach the db file and some example with the original text to test it? I cant see what’s the problem

PaperOrb commented 2 years ago

Hey @RafaelGB, here's the DB and a file to test it with: folder db test.md FINAL FANTASY VII (2013).md

RafaelGB commented 2 years ago

thanks! Will be added to bugs in roadmap

mProjectsCode commented 2 years ago

The notes seem to be generated by my Media DB Plugin.

For that plugin, I wrote my own YAML stringifier that consistently adds quotation marks around strings. Mostly because I prefer it that way.

I am guessing that the db folder plugin replaces the entire frontmatter block and uses the obsidian API YAML stringifier for that.

RafaelGB commented 2 years ago

hi @mProjectsCode . I am afraid that the plugin use the dataview parser with all the fields. I added a proxy between to give it some value with quotes in some cases. I can add more uses cases to fix your issue

mProjectsCode commented 2 years ago

thanks for the quick answer.

I personally think a setting to always add quotation marks to strings would be nice.

That also seems to be the simplest way to resolve the small "conflict" between our plugins. I will also work on an option to only add quotation marks only where it is necessary for my plugin.

RafaelGB commented 2 years ago

We can collaborate to obtain the best parsing. In src/services/DataviewService.ts is the behaviour of the writing quotes:

private handleMarkdownBreaker(value: string, isInline?: boolean): string {
        if (isInline) {
            return value;
        }
        // Check possible markdown breakers of the yaml
        if (MarkdownBreakerRules.INIT_CHARS.some(c => value.startsWith(c)) ||
            MarkdownBreakerRules.BETWEEN_CHARS.some(rule => value.includes(rule)) ||
            MarkdownBreakerRules.UNIQUE_CHARS.some(c => value === c)) {
            value = value.replaceAll(`"`, `\\"`);
            return `"${value}"`;
        }

        return value;
    }
RafaelGB commented 2 years ago

New property added to select your editing preferences

https://user-images.githubusercontent.com/11924043/174895284-bc49ad22-6077-4065-ae6c-9403b570086c.mov

mProjectsCode commented 2 years ago

Looks great, except that it also adds quotation marks around non-strings like booleans and numbers.

RafaelGB commented 2 years ago

Fixed too :)