obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Empty value in bracketed inline data overwriting default value in table

Open spasticginger opened this issue 2 years ago • 5 comments

What happened?

Screenshot_20220316-143515

This error occurred on both deesktop & mobile versions of Obsidian

Frontmatter & unbracketed key-value pairs performed as expected, however an empty bracketed inline data overwrites a table's default value with blank. Screenshot of source & preview mode attached.

issue can be recreated :


Test1:

Test2:: [Test3::]

DQL

Table
  default(Test1, "👽") AS "1",
  default(Test2, "🛸") AS "2",
  default(Test3, "🐮") AS "3"
WHERE Type = "Test"

JS

No response

Dataview Version

0.4.26

Obsidian Version

0.13.33

OS

Windows

spasticginger avatar Mar 17 '22 03:03 spasticginger

  • A value in Test3 renders properly in the DV Table

In Discord, was asked to also run ' = this` query. Results attached

Screenshot_20220316-145700.png

Also, was asked to reassign issue to @AB1908 but I can't seem to find a way to do that (using mobile GitHub)

spasticginger avatar Mar 17 '22 03:03 spasticginger

Test1 and Test2 evaluate to undefined and null. Test2 is not indexed at all as you can see here: image

default, per the docs, changes default values for values that are null, and also appears to work for undefined. However, Test3 has an empty string "", which is not null, which is why the field is not populating as you expect it to.

AB1908 avatar Mar 17 '22 14:03 AB1908

Ah that makes sense now! I didn't realize the brackets would automatically make it a blank string, whereas the other formats don't.

Thank you for your help!!

Admittedly I was using the brackets primarily just to be able to target the data with CSS. Is there a way to target the Test2 format? If not, I totally understand, styling kind of goes beyond the point of reading & working with raw data.

spasticginger avatar Mar 18 '22 05:03 spasticginger

I'm not aware of how to apply CSS to inline fields. Let me poke around and get back to you.

AB1908 avatar Mar 18 '22 19:03 AB1908

Sorry for the late check on this but any progress? I would appreciate a check since there have been some improvements to the parser. If not, I'll dig it up again.

AB1908 avatar Aug 04 '22 11:08 AB1908

Hello, sorry to come back to you so late. I currently go through older issues to see which are stale or already solved.

Theres a FR in #713 to be able to style non-bracketed inline fields. If I get you right, that's what you want to have? If this is the only open point on this issue and if it's okay, I'd like to close the issue in favor or #713.

That the bracketed inline field is set to an empty string as value is intended behaviour, as far as I can tell - in fact, it is the only way I am aware of to use an empty value.

s-blu avatar Dec 16 '22 19:12 s-blu