Closed harryadel closed 2 years ago
I guess it's good to go @Prinzhorn. Any last comments?
@Prinzhorn Kindly recheck.
Thanks!
LGTM
@harryadel would be nice if we could set this per collection or somehow disable it for a specific operation. Now looking at this I think I have a bug in one of my apps where this is trimming a place that should not be trimmed.
would be nice if we could set this per collection or somehow disable it for a specific operation
Can't you do exactly that already?
Per collection: unless you are re-using a schema, you can pass clean
to the SimplSchema
constructor https://github.com/longshotlabs/simpl-schema#set-default-options-for-one-schema
Per operation: https://github.com/Meteor-Community-Packages/meteor-collection2#inserting-or-updating-without-cleaning
@Prinzhorn You can add the updated version to your app now.
@StorytellerCZ huh, that's weird. Will you please open up an issue so we can better track this?
I just upgraded and unfortunately it does not work as expected and I wonder if it ever did.
Prior to this PR there was a const with the default clean options
and for every clean action it was merged together with the clean option defined on the schema level plus the ones passed to this particular call
I was assuming schema._cleanOptions
could be unset, otherwise (schema._cleanOptions || {})
would not make sense.
However, it is never undefined and simpl-schema already has a set of defaults:
What this means is that defaultCleanOptions
(now Collection2.cleanOptions
) never did anything. Maybe nobody noticed because the options are identical to the simpl-schema defaults anyway.
What that means is:
Are my observation correct?
My use-case would be possible, however, via a different global setting that defaults to {}
and is merged after schema._cleanOptions
, but I think this entire thing is a mess and it should probably not be made more complex. In the end nobody will understand where the options actually come from.
@Prinzhorn Great write up and analysis.
Indeed since ...(schema._cleanOptions || {})
is set after ...defaultCleanOptions
it overrides any values you'd set in defaultCleanOptions
rendering it meaningless.
What this means is that defaultCleanOptions (now Collection2.cleanOptions) never did anything. Maybe nobody noticed because the options are identical to the simpl-schema defaults anyway.
You're right, I guess it was set as precautionary measure in case simple schema values were not present for any reason.
it can be entirely removed What I was hoping for in Expose defaultCleanOptions #432 seems impossible given the way simpl-schema handles the clean options
I might release a fix/feature removing it altogether but I don't think we're in a hurry though.
My use-case would be possible, however, via a different global setting that defaults to {} and is merged after schema._cleanOptions, but I think this entire thing is a mess and it should probably not be made more complex. In the end nobody will understand where the options actually come from.
We end up looping back to the original point. This should be handled within simpl-schema and none of collection2 concern. But hey, we learnt something along the way so thank you for that! <3
Indeed since ...(schema._cleanOptions || {}) is set after ...defaultCleanOptions it overrides any values you'd set in defaultCleanOptions rendering it meaningless.
This case should've accounted for in the tests and we should've listened for schema clean options instead of collection2 property.
@Prinzhorn wouldn't this problem be solved if set defaultCleanOptions
after ...(schema._cleanOptions || {})
but we then end up tampering with simpl-schema options. Honestly this whole entire debacle of how to simple schema clean options should work is out of collection2 goals.
Honestly this whole entire debacle of how to simple schema clean options should work is out of collection2 goals.
I agree, that's what I meant with
but I think this entire thing is a mess and it should probably not be made more complex. In the end nobody will understand where the options actually come from.
Originally I thought since collection2 already has defaultCleanOptions
it would be a no-brainer to expose it. But now that I know more about the situation it's not worth the added complexity like you said.
https://github.com/Meteor-Community-Packages/meteor-collection2/issues/432