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

Fix Composite::addAfter(null) aggregation behavior #1877

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

romainneutron
Copy link
Contributor

Elastica\Aggregation\Composite::addAfter accepts null value. However, it's not allowed by elasticsearch It returns an error: [composite] after doesn't support values of type: VALUE_NULL

This PR fixes this bug

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -25,6 +25,10 @@ public function addSource(AbstractAggregation $aggregation): self
*/
public function addAfter(?array $checkpoint): self
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot we deprecate passing null? So that we can change the type-hint in 8.0 to only allow array and remove the check for null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be in favor of keeping it, It's very handy for writing code:

do {
    $result = $this->doYourAggregation($after ?? null);

    // ...

    $after = $result->getAggregations()['composite']['after_key'];
} while (true);

@romainneutron
Copy link
Contributor Author

PR rebased

Copy link
Owner

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@deguif WDYT?

@ruflin ruflin merged commit b1b6c98 into ruflin:master Dec 10, 2020
@romainneutron romainneutron deleted the add-after-null branch December 11, 2020 15:08
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.

3 participants