Issues with "where" clause in queries with @page.name

Hi again, sorry for opening another troubleshooting topic. I am still in the process of transioning some stuff from pre 0.7 to the current version, and I can’t make some older queries to work.

So I have one example page called proj1 living in a Projects folder.

Then I have a second page called action1 living in an Actions subfolder. This action page has the following frontmatter:

---
created: "2024-02-03"
start_date: null
due_date: null
end_date: null
status: "active"
project: "proj1"
priority: null
tags: action
---

I would like to see this action in the proj1 page (and any other action with the project: proj1 in frontmatter). Before I was using the following query (simplified here) on the proj1 page:

action where project = {{@page.name}}

But if I apply this now (with or without curly brackets) I get no results:

What was weird is that a query like action where status = active, works flawlessly, what I am missing?
I went through the Live Queries and and Query Language docs but I don’t see anything wrong with the above approach.

Ok, so when you use action where project = {{@page.name}} what that should do is string-replace {{@page.name}} with whatever the current page name is.

So if you’re on “My Cool Page” this would translate to action where project = My Cool Page which is syntactically incorrect (missing quotes).

Two solutions: action where project = @page.name (so no curly braces), or action where project = "{{@page.name}}" add quotes. Do either of those work?

Unfortunately they both return the same empty box as before. Could the action frontmatter cause some weird issue?

Ah, the problem is the “in the Projects” folder bit. You’re doing an exact match, meaning action where project = @page.name would translate to action where project = "Projects/project1" which wouldn’t match, because it’s set to project1. What you could do — although a bit hacky — is get rid of the Projects/ prefix:

action where project = replace(@page.name, /^Projects\//, "")

1 Like

How to debug these things in general: write some simpler queries and see what the values actually are. It’s easy to just use a temporary template to find these things out:

```template
Matching project against {{@page.name}}
in query:

{{{action select project}}}
```
1 Like

Uh, yeah makes total sense. I switched to folders when upgrading to 0.7, that’s also why I didn’t have that issue before. The hacky solution works, I’ll see if it’s worth switching back to no folders or keep the hack, thanks a lot for the help :slightly_smiling_face:

And thanks for the debugging suggestion, I’ll keep that in mind ^^

1 Like