Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ancestor/parent predicates can return incorrect results #365

Closed
kofm opened this issue Aug 6, 2023 · 4 comments
Closed

ancestor/parent predicates can return incorrect results #365

kofm opened this issue Aug 6, 2023 · 4 comments
Assignees
Labels
Milestone

Comments

@kofm
Copy link

kofm commented Aug 6, 2023

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!

@alphapapa
Copy link
Owner

Hi,

Thanks for reporting this. I can confirm the bug. I don't know why it's happening, but I'll investigate when I have time.

In the meantime, I noticed that these queries seem to behave as expected, so you could use them while waiting for a fix:

'(parent (heading "Test"))
'(parent (rifle "Test"))

@alphapapa alphapapa self-assigned this Aug 8, 2023
@alphapapa alphapapa added the bug label Aug 8, 2023
@alphapapa alphapapa added this to the 0.7.1 milestone Aug 8, 2023
@alphapapa alphapapa modified the milestones: 0.7.1, 0.7.2 Sep 6, 2023
@alphapapa
Copy link
Owner

Several smaller fixes are due to be made in 0.7.x releases, and this bug doesn't seem new, so I'm going to defer it until 0.8.

@alphapapa alphapapa modified the milestones: 0.7.2, 0.8 Sep 14, 2023
@alphapapa alphapapa modified the milestones: 0.8, 0.9 Dec 16, 2023
@alphapapa alphapapa changed the title Unexpected behavior with parent selector ancestor/parent predicates can return incorrect results Feb 21, 2024
@alphapapa alphapapa modified the milestones: 0.9, 0.8.5 Feb 21, 2024
@alphapapa
Copy link
Owner

Finally, this is fixed. It took a lot of digging. Thanks for your patience.

@kofm
Copy link
Author

kofm commented Feb 21, 2024

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants