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

Unable to set Custom Date for Index Id before Adding event handler #103

Merged
merged 2 commits into from
Nov 7, 2023

Conversation

niemyjski
Copy link
Member

Added a test that shows off that monthly/daily indexes are failing due to unable to set custom date via event handler. Custom dates are set before the handler this preventing us from having custom logic before the document id is created.

    private async Task OnDocumentsAddingAsync(IReadOnlyCollection<T> documents, ICommandOptions options) {
        if (HasDates)
            documents.OfType<IHaveDates>().SetDates();
        else if (HasCreatedDate)
            documents.OfType<IHaveCreatedDate>().SetCreatedDates();

        documents.EnsureIds(ElasticIndex.CreateDocumentId);

        if (DocumentsAdding != null && DocumentsAdding.HasHandlers)
            await DocumentsAdding.InvokeAsync(this, new DocumentsEventArgs<T>(documents, this, options)).AnyContext();

        await OnDocumentsChangingAsync(ChangeType.Added, documents, options).AnyContext();
    }

@niemyjski niemyjski added the bug label Nov 7, 2023
@niemyjski niemyjski self-assigned this Nov 7, 2023
…t handler

I didn't make the same change to saving as the id should already be resolved for any save and is needed for the join.
@niemyjski niemyjski merged commit 26fab37 into master Nov 7, 2023
3 checks passed
@niemyjski niemyjski deleted the bugfix/unable-to-set-custom-document-date branch November 7, 2023 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant