blacksmithgu / obsidian-dataview

A data index and query language over Markdown files, for https://obsidian.md/.
https://blacksmithgu.github.io/obsidian-dataview/
MIT License
7.07k stars 416 forks source link

Bug report contains field not behaving correctly depending on the data in inline field #2227

Open blu3knight opened 9 months ago

blu3knight commented 9 months ago

What happened?

There are two Examples: Example 1 the data field contains a singular item. example mydata:: [[item1]]

In the dataview search if you do where contains(mydata, [[item1]]) the data comes up correctly in the table

Example 2 the data field contains more then 1 item. example mydata:: [[item1]] | [[item2]]

In the dataview search if you use the same contains as above where contains(mydata, [[item1]]), nothing comes up. If you use where contains(mydata, "[[item1]]") then it comes up correctly.

But if I use the same quotes in a singular item in Example 1 nothing comes up, unless I add something else on the line any other character makes it come up. This defeats the purpose of conformity if you need to identify if there is a singular item in the object and then have to modify the query accordingly

If you are using the boolean logic contains should not care how many items are in the field and should pull up the data on a match.

Recommendation pick one or the other, but make it work in a true boolean fashion searching for the item in the field (contain) vs =

DQL

No response

JS

No response

Dataview Version

0.5.64

Obsidian Version

1.5.3

OS

Windows

holroy commented 9 months ago

You can counter this difference in behaviour related to a field having a single value or is a list of value by doing flat(list( yourFieldName ). This will ensure that it's always a list, and you can use the list tools to do your checks. If I get around to it soon, I'll hopefully add a zip(fieldName) which would do the same (plus some other new functionality to join various fields together into a new array, but until then you can use the flat(list( ... )) trick to ensure you've got a consistent way to treat your fields.