Skip to content

Metadata calculated from inline DQL or DVJS queries is always unbound to the page #2509

Open
@iredelmeier

Description

What happened?

It seems that whenever metadata is calculated inline queries leveraging this (DQL) or dv.current() (DVJS - either directly or through code supplied through dv.view) aren't bound to the original page's context.

For example, given:

// view.js
return dv.current().foo
%% foo.md %%
foo:: hello
dql:: `= this.foo`
dvjs:: `$= dv.current().foo`
dvjsView: `$= await dv.view('view.js')'
%% bar.md %%
## DQL

```dataview
TABLE WITHOUT ID
	file.name,
	file.path,
	foo,
	dql,
	dvjs,
	dvjsView,
WHERE
	file.name = this.file.name
OR
	file.name = `"foo"`
```

## DVJS

```dataviewjs
const pages = [dv.current(), dv.page('foo')];

dv.table(
	['path', 'foo', 'dql', 'dvjs', 'dvjsView'],
	pages.map(page => [page.file.path, page.foo, page.dql, page.dvjs, page.dvjsView])
)
```

The file with the main queries will render as:

A DQL and DVJS table, both with the same incorrectly calculated metadata

Based on the docs and previous discussion, it seems like this is expected to (and used to!) at least work when the inline query used as a view and/or the main query used JS.

However, with #170 still open, maybe it actually isn't expected to work at all? It definitely makes sense that the implementation might be difficult and not necessarily worth either the effort or potential performance hit. I'm happy to submit a quick PR updating the docs based on this assumption!

DQL

No response

JS

Dataview Version

0.5.67

Obsidian Version

1.7.7

OS

MacOS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions