Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where statement is missing files when searching for properties #2489

Open
KleiDav opened this issue Dec 5, 2024 · 5 comments
Open

Where statement is missing files when searching for properties #2489

KleiDav opened this issue Dec 5, 2024 · 5 comments
Labels
bug Something isn't working.

Comments

@KleiDav
Copy link

KleiDav commented Dec 5, 2024

What happened?

In my vault, this DQL below shows only 27 records when I have 45 files with the property "type_note" equals to "knowledge_base"
Tried with other properties, it always misses files.

So what I did is add the tag #kbase to those 45 files, and by changing the DQL to "from #kbase" instead of "where type_note="knowledge_base"" I can now see my 45 files listed.

So to me, doing a request on a property is not showing the real informations.

DQL

table 
where type_note="knowledge_base"
sort file.name desc

JS

No response

Dataview Version

0.5.67

Obsidian Version

1.7.7

OS

Windows

@KleiDav KleiDav added the bug Something isn't working. label Dec 5, 2024
@holroy
Copy link
Contributor

holroy commented Dec 28, 2024

What do you get if you do the following query:

```dataview
TABLE
WHERE contains(flat(list(type_note)), "knowledge_base")
SORT file.name desc
```

If this query produces all your files, then it's not a bug but a feature that some of your type_note properties are lists, instead of a single value. The syntax is above is useful to force both single values and lists into a coherent list structure. I found it when needing to query old metadata from before the property update in Obsidian where it was common to intermix properties/fields with either a list or a single value.

@KleiDav
Copy link
Author

KleiDav commented Dec 28, 2024

In fact, my ‘note_type’ is a list and by using this syntax I can see all my notes!
Thanks a lot!

@holroy
Copy link
Contributor

holroy commented Dec 28, 2024

If they're always a list, and never a single value, that is something: singleValue, you could use contains(yourListProperty, "value") to check whether the list has that value.

@KleiDav
Copy link
Author

KleiDav commented Dec 29, 2024

Thanks, I prefer the second syntax, easier to understand :-)
By the way, do you know if possible to force no more than a single value on the property?

@holroy
Copy link
Contributor

holroy commented Jan 1, 2025

If the property is not declared as a list, it's by default just a single value. So in that case, it'll remain a single value and can be used as such until you change your usage of that property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants