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

[5.x] Add always_augment_to_query option #11086

Merged
merged 3 commits into from
Nov 21, 2024

Conversation

jacksleight
Copy link
Contributor

@jacksleight jacksleight commented Nov 7, 2024

Replaces #9979 (maybe), see #9979 (review).

This PR adds an always_augment_to_query option that when enabled ensures that relationship fields always augment to a query builder, instead of the current behaviour where single (max_items: 1) relationships return the related entry.

The main reason to do this is to make the API more consistent and allow altering the single relationship queries (which are limited to published entries only by default). But unfortunately it does have other side effects as this will no longer work:

{{ product:title }}

Instead you have to do this:

{{ product }}{{ title }}{{ /product }}

I'm guessing this may be the reason for the original behaviour in the first place?

Ideally the first method should still work, I don't know if there's a way to get the antlers parser to figure it out and run the query if a property name has been appended?

If this is merged it shouldn't be breaking as it's opt-in.

@jacksleight jacksleight changed the title Add always_augment_to_query option [5.x] Add always_augment_to_query option Nov 7, 2024
@jasonvarga
Copy link
Member

I'm guessing this may be the reason for the original behaviour in the first place?

Yup.

Ideally the first method should still work, I don't know if there's a way to get the antlers parser to figure it out and run the query if a property name has been appended?

There's probably a way. But since this behavior is opt-in and not breaking, we could always update the parser to support this later.

@jasonvarga jasonvarga merged commit 54f3d3f into statamic:5.x Nov 21, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants