obsidian-dataview
obsidian-dataview copied to clipboard
Empty aliases: in front matter results value: "null" string
What happened?
See this conversation for details: https://github.com/zsviczian/excalibrain/issues/83
In summary leaving aliases:
in the frontmatter empty result in page.alisases.values = ["null"]
instead of values=[]
.
instead of this
{
"aliases": {
"values": [
"null"
],
}
I think it should be rather this:
{
"aliases": {
"values": [],
}
@SunnyOd can you provide the dataview and obsidian version and operating system you are using?
DQL
No response
JS
No response
Dataview Version
N/A
Obsidian Version
N/A
OS
Windows
Haha this is a good one. Does this happen in the metadataCache as well?
@SunnyOd can you provide the dataview and obsidian version and operating system you are using?
DQL
Sure... I'm on:
- Fedora Linux (i3 Spin): 5.18.16-200.fc36.x86_64
- Obsidian: 0.15.9
- Dataview: 0.5.41
You probably want file.aliases
, not aliases
- the top level metadata in dataview pages are just literal copies of whatever your frontmatter + inline fields are.
@blacksmithgu, I'm using file.aliases
.
In this case top level aliases
is better, though still not good. It holds an item of value [null]
not ['null']
, but at the moment I am checking if aliases.length > 0
which in both cases will result in a false positive. I could change the logic, however I think instead of [null]
and ['null']
it would be more proper to have []
.
Here's my code for reading aliases: https://github.com/zsviczian/excalibrain/blob/e5031ede20dd04737e4568471ea3b0d35b0786c8/src/graph/Page.ts#L152-L158
@AB1908, it seems the value is [null]
in metadatacache
I raised a question with Licat on OMG on the topic of [null] vs. []. I can argue for both, but on balance I still feel that [] would be cleaner. https://discord.com/channels/686053708261228577/840286264964022302/1009707558388367460
Ah, I see. The difference here is
aliases:
-
Versus
aliases:
The first one pretty clearly looks like [null]
to me, at least going by the YAML spec. I could also maybe see [""]
, but I don't think []
is a valid parse unless you make a special case for the treatment of aliases.
Thanks!
[""]
is definitely better than ["null"]
.
I will add additional validations to my logic to check if value is null
or ""
.
Feedback from Licat referring to [null]
:
That's literally how yaml parses empty fields. Internally we have a function to type check and recognize things like aliases.
Thus the thing to consider is if you want to change DataView at the file level from ["null"]
to either [null]
or [""]
.
Upon reflection, in don't think it's a breaking change to just have dataview eliminate empty strings and nulls and return []
.