meteor-publish-composite icon indicating copy to clipboard operation
meteor-publish-composite copied to clipboard

Unset fields are not unset

Open derwaldgeist opened this issue 2 years ago • 3 comments

Assume we have a document that looks like this:

{
    _id: '4711',
    food: {
        fruit: ['apple']
    }
}

I now unset property fruit completely, so the document looks like this:

{
    _id: '4711',
    food: {
    }
}

However, publishComposite will still report the unset property to the client, so it still looks like this:

{
    _id: '4711',
    food: {
        fruit: ['apple']
    }
}

This is also how the document looks if it is passed to any children.

Hence, the database and publishComposite get out of sync in the case a field is being unset.

Interestingly, if I reload the browser tab so the subscription is run for the first time again, the content updates (i.e. the field is unset).

I've not experienced this behaviour with regular Meteor subscriptions, so I guess this is due to some caching inside publishComposite.

derwaldgeist avatar Mar 11 '23 11:03 derwaldgeist

Thank you for submitting this issue!

We, the Members of Meteor Community Packages take every issue seriously. Our goal is to provide long-term lifecycles for packages and keep up with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.

However, we contribute to these packages mostly in our free time. Therefore, we can't guarantee your issues to be solved within certain time.

If you think this issue is trivial to solve, don't hesitate to submit a pull request, too! We will accompany you in the process with reviews and hints on how to get development set up.

Please also consider sponsoring the maintainers of the package. If you don't know who is currently maintaining this package, just leave a comment and we'll let you know

github-actions[bot] avatar Mar 11 '23 11:03 github-actions[bot]

Could this be part of #146 ?

StorytellerCZ avatar Sep 23 '23 13:09 StorytellerCZ

@derwaldgeist what publication strategy are you using? publish-compose relies on SessionCollectionView internals in order to deduce what fields need to be unset. If you are using anything else than SERVER_MERGE, unsetting won't work properly.

alisnic avatar Feb 02 '24 08:02 alisnic