dendron icon indicating copy to clipboard operation
dendron copied to clipboard

Schema template does not get populated when `namespace: true` is set

Open rlh1994 opened this issue 2 years ago • 1 comments

Please select the area your bug applies to. (Multiple selections are Possible. You can leave blank if you're not sure.)

  • [ ] Workspace. VSCode workspace, vaults, Intellisense/autocomplete, Dendron settings
  • [x] Lookup. Dendron's Lookup Command
  • [ ] Views. Dendron Preview, Tree View, Side Panels in the UI
  • [ ] Schema. Dendron Schemas
  • [ ] Pod. Data import from / export to Dendron
  • [ ] Publish. External Site Publish
  • [ ] Markdown. Markdown features, such as syntax support and features

Describe the bug

When a schema is created and a level has both a template and namespace: true is set then the notes created at this and all subsequent levels do not get populated with the template. Removing the namespace: true correctly populates the template

To Reproduce

Steps to reproduce the behavior:

  1. Create a schema file as follows:
        version: 1
        imports: []
        schemas:
          - id: test
            children: 
              - testing
            title: test
            parent: root
          - id: testing
            pattern: "*"
            title: "testing"
            # namespace: true
            template:
              id: template.test
              type: note
    
  2. Create some template.test with literally anything in it
  3. Create a note called test.test1 - it should be populated with your template
  4. Uncomment the namespace line in the schema and save
  5. Create a note called test.test2 and test.test2.test3 and see neither are populated with the template.

Expected behavior

Namespace set to true should apply the template to that and all subsequent levels in the namespace

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information)

  • OS: Windows
  • Versions (all that apply to bug):
    • Dendron Extension: 0.107.2
    • VS Code version: 1.68.1
    • Dendron CLI: N/A

Additional context

Dendron Log file

rlh1994 avatar Aug 11 '22 10:08 rlh1994

I'm seeing the same behavior, where templates are only successfully applied if the schema uses the pattern: "*" construction.

For whatever it's worth, I don't think this is recently introduced behavior, and I also think it's a bug. I remember being very confused by this when I set up my own schemas and templates a while ago, but I assumed at the time I was just misunderstanding something. The schemas I currently use with templates rely on the pattern: "*" construction.

ryan-p-randall avatar Aug 11 '22 18:08 ryan-p-randall

Thank you for the report. I can reproduce this. Taking a look!

hikchoi avatar Aug 12 '22 04:08 hikchoi

@rlh1994 A fix should go out either with the next release or the release after that.

Note that namespace schema nodes only match with the note with an exact match, and its immediate children. It does not recursively go down to an arbitrary note depth. So not all subsequent levels under the namespace will have the schema (and the template) applied.

See: https://wiki.dendron.so/notes/c5e5adde-5459-409b-b34d-a0d75cbb1052/#namespace

making a schema node a namespace automatically brings its immediate children as part of the schema, even if they are not explicitly defined in the schema definition. it will also automatically set the pattern to {namespace}.*

This was a bug that went unnoticed for quite a long time 🙂 thanks for catching it!

hikchoi avatar Aug 12 '22 11:08 hikchoi

@hikchoi thanks! Is there any way to go to an arbitrary depth with the template currently? Or should I submit a feature request for that?

rlh1994 avatar Aug 12 '22 12:08 rlh1994

Not currently, that would be a feature request

On Fri, Aug 12, 2022 at 5:03 AM Ryan Hill @.***> wrote:

@hikchoi https://github.com/hikchoi thanks! Is there any way to go to an arbitrary depth with the template currently? Or should I submit a feature request for that?

— Reply to this email directly, view it on GitHub https://github.com/dendronhq/dendron/issues/3381#issuecomment-1213039583, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABPIPT2MYWANE742ZBJO43VYY4Q7ANCNFSM56HW74QQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

kevins8 avatar Aug 12 '22 14:08 kevins8

The fix has been shipped with v109. Please give it a try again and let us know if there are outstanding concerns related to this problem.

hikchoi avatar Aug 24 '22 04:08 hikchoi

This issue has been automatically closed because there has been no response to our request for more information from the original author. We don't have enough information to take action. Please reopen if the question from the maintainer has been answered and the issue is still valid.

github-actions[bot] avatar Aug 27 '22 05:08 github-actions[bot]