Skip to content

ancestor/parent predicates can return incorrect results #365

Closed
@kofm

Description

@kofm

Hello,
I am encountering an unexpected result when using the parent query selector in org-ql. I have the following org file structure:

Description

* Test
** Foo
* Not to be shown
** Bar

When I run the following query:

(org-ql-search "/tmp/test.org" '(parent "Test"))

I expect only to get the 'Foo' result, as it's the only heading with "Test" as a direct parent. However, the query returns both 'Foo' and 'Bar'.

Expected Behavior

According to the docstring for the parent selector:

parent (&optional query)
Return non-nil if current heading has a direct parent heading. If QUERY, return non-nil if the parent heading matches it. This selector may be nested, e.g. to match grandparent headings.

I expected the query to return only headings with "Test" as their direct parent. In this case, only 'Foo' should match the query.

Actual Behavior

The query returns both 'Foo' and 'Bar', which seems inconsistent with the docstring definition of the parent selector.

I hope I have understood the documentation, and I would appreciate any clarification or assistance in resolving this issue.
Once again, I'd like to express my gratitude for your efforts on the org-ql package. It's genuinely invaluable to my Emacs experience.
Thank you!

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions