-
Notifications
You must be signed in to change notification settings - Fork 130
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
Change from non-existent to false not being tracked #256
Comments
Looks like a bug. Want to try to write a (failing) spec for it and maybe a fix? |
No, it’s actually on purpose (at least going by it being tested for 😆). According to the test (starting on |
I completely agree with you. For backwards compatibility I would introduce an option ( |
@dblock I think it's safe to change the
Either of the above would still consider empty array values as "blank" which I think is desirable here. |
@johnnyshields Possibly. As long as no existing specs fail and we document it thoroughly. |
Just dropping the On using |
My take is:
I think this can probably be done without a config flag, or if we do add one, deprecate it and remove it in the next major version. |
I’m not sure why you would want to track just some changes. In my case I definitely want the first two tracked, and maybe the 3rd, although I’d have to look at where we use such fields to be sure (and if I don’t need it tracked, that also means it won’t hurt anything if it’s suddenly tracked). But really, I don’t think mongoid-history should be making any implicit assumptions about what someone may or may not want tracked (except |
In my case it's more about showing the changes to the end users. I'd prefer to skip trivial changes, it's just noise for me. |
Which kind of makes my point. It’s noise to you, it’s definitely not to me. mongoid-history has no way to know our different needs so shouldn’t be making those kinds of assumptions, it should support both use cases IMO. |
I say let's see a PR from @BrianLMatthews and we can discuss whether to merge/not merge it? |
Before I do a PR I’d like to at least agree on a general approach. My suggestion (and what I’d do in a PR) would be:
So it will work as now out of the box. If someone adds If that’s ok I’ll start on a PR (it won’t be done immediately, pesky real job and such). I’ve read through |
@BrianLMatthews this looks fine, I think should separate "False" from "Blank" in this context. |
Naming-wise I think Semantically this is incorrect, but I can't come up with a better option. "Track blank" means "track blank change history", but |
I see that as a separate issue. I, personally, don’t think mongoid-history should be doing any implicit filtering of changes, and certainly not any that can’t (easily) be turned off by the user. So I’d like to keep this issue just allowing the current implicit filtering to be turned off. Any changes to that filtering would be a separate issue, although I will note that once the implicit filtering can be turned off, any filtering desired can be handled by a custom changes method (something that can’t be done today).
I was thinking about the naming of the option, as I’m not happy with what I suggested either. I think the problem though is that it’s a “reversed” option, i.e. |
I would vote to call it |
I'm good with what @johnnyshields is suggesting, possibly as a start ;) |
Ok, I'll start on a PR. |
In a model I have:
When the document is initially created, the
exclusion
field doesn’t exist. Later it gets set, and if it’s set tofalse
, the change isn’t tracked. I’ve tracked things down to line 29 inlib/mongoid/history/attributes/update.rb
:It’s the
v.all
that’s the problem.v
at that point is[nil, false]
, and bothnil
andfalse
areblank?
so it’s not tracking that change. While that’s clearly on purpose it seems wrong. Changing something from non-existent tofalse
is a change (mongoid thinks so or it wouldn’t be inchanges
), so it seems it should be tracked (assuming all other things say it should be tracked). Thoughts?The text was updated successfully, but these errors were encountered: