Inline fields with any characters

In this question
the accepted solution to include fields with special symbols in them is to use the row syntax. That doesn’t work for me when I have a brace: e.g.

rating (1-10):: 6

and then query

dataview
table row[“rating (1-10)”]

I just get “-”, as if the field doesn’t exist. What am I doing wrong?

The parentheses seems to be the issue. You could try…

[rating {1-10}:: 6]
```dataview
table row["rating {1-10}"]
WHERE contains(file.name,this.file.name)
1 Like

Why are the normal parenthesis an issue? Can I escape them?

:man_shrugging: I don’t know? You can always try. I did but I wasn’t successful.

https://blacksmithgu.github.io/obsidian-dataview/annotation/add-metadata/#inline-fields

And your spot on that the field do not exist with those. Using the test document below, you can see that neither rating nor rate is identified as fields. Hi there on the other hand is defined as a field in both its full form and the normalised form.


Test document used to check fields:

Testing some stuff

rating (1-10):: 6

More text and then [rate(1-10):: 7], and some more [Hi there:: 8]

```dataviewjs 
let data = dv.current()
delete data.file
dv.paragraph(data)
```
2 Likes

Well, I guess I will accept FsOver2’s answer as solution, since you just proved that it is the only crutch possible in the buggy world of dataview…

I don’t really see this as a bug. In computer programming, there are special characters that can’t be used as variables, keys, fields, etc. In this case, parentheses seem to be problematic in field names. I’m actually impressed with how many characters are allowed to be used in field names.

I tried a couple more options. One uses escaped html, the other uses “emoji” brackets in place of regular parentheses. Neither seems like a great solution to me. I wasn’t ever able to figure out how to escape the parentheses in the Dataview query.

The following works for me…

Escaped html

[rating (1-10):: 6]

Emoji Brackets

[rating(1-10):: 7]

Query

```dataview
TABLE row["rating (1-10)"], row["rating(1-10)"]
WHERE contains(file.name,this.file.name)

I really liked your Dataview JS query. Very compact notation! This will go into my bag of tricks! :grin:

OK, I changed my mind. I think this could be bug with inline fields. If I create a frontmatter property, which is different from an inline field, I can use a parenthesis in the property name. The below example works just fine.

---
rating (1-10): 6
---

```dataview
table row["rating (1-10)"]
WHERE contains(file.name,this.file.name)

Using the dataviewjs code @holroy suggested, I found there wasn’t any way to have the inline field recognized if a standard parenthesis was included in the field name. The issue isn’t escaping the characters in the query, the issue is the inline field is never created in the first place.

If this is something that bothers you, you could submit a bug report to the Dataview plugin GitHub.

As parentheses have a discrete inline function in Dataview—to hide keys in reading mode—isn’t it implicit that they can’t be used in other ways? :thinking:

As an alternative:

[rating_(1-10):: 6]


```dataview
table rating_1-10 As "Rating 1–10"
WHERE file.name = this.file.name
```

1 Like

Good point.

Just for clarity to future readers, the parentheses in this example are “emojis”, not your standard latin parentheses.

1 Like

Yep, just one of the alternative sets of parentheses available in Unicode and UTF-8. Didn’t try them all.

FULLWIDTH LEFT PARENTHESIS
Unicode: U+FF08, UTF-8: EF BC 88

FULLWIDTH RIGHT PARENTHESIS
Unicode: U+FF09, UTF-8: EF BC 89

1 Like