-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(filterFilter): filter deep object by string #10401
Conversation
CLAs look good, thanks! |
Enable filterFilter with string expression to filter objects with deep properties. It used to work like this before angular#9757 and v1.3.6.
4ea9af0
to
0538dc0
Compare
This was deliberate and was implemented as part of the algorithm described in #9757 (comment) (near the bottom of the comment):
Key phrase is "the corresponding There is even a test that ensures So, basically, this works as expected (imo), since:
That said, I was planning (but somehow forgot) to propose a new special property name (e.g. WDYT, @caitp, @petebacondarwin ? |
@gkalpak I think we should fix this, I didn't notice that change at all. No breaking changes please. I'm not sure this fix is what I'd go with since it is damned unreadable though |
@caitp: Let's don't have another long debate on what is/isn't a breaking change and focus on what we want implemented instead 😄 Previously, deep expression objects weren't really supported, so the semantics of `$` were more straight-forward.Basically, I see three possible options (feel free to suggest others):
FWIW, I hate option (1) and favor option (3); probably (3a) to avoid "breaking broken expected behaviour". |
well it is a breaking change, we can't do that in 1.3 =\ |
@caitp: Sure, I give up; it's a breaking change. If you could point out which of the options above is the indicated solution (or suggest something else), I would be very glad to submit a fix 😕 |
How about, |
Maybe I am missing something here but I would suggest that this is actually a regression that needs to be fixed. If you simply pass in a string to |
@petebacondarwin you aren't missing anything, that's exactly the issue --- whether it's called a regression or a breaking change. We need to fix this for monday :< |
I will submit a fix later today, implementing @caitp's suggestion of having |
@gkalpak - great!! Thanks |
I've updated the code to have |
@shuhei: Your current implementation makes all string properties in the expression object to match any property (as if their key were var items = [{level1: {level2: 'test'}}];
var expr = {level1: 'test'};
expect(filter(items, expr).length).toBe(0); |
@gkalpak Thanks for pointing it out. But should the test pass in v1.3.x? It fails in v1.3.5 at least. IMHO, everything including |
Yeah, I'm pretty sure that was a bug in the previous implementation, it is not documented as behaving like that. We will need to include notice of this in the fixed version though. |
keep it open, we'll close on merge |
@caitp: What do you mean by "include notice of this" ? In the docs ? In the commit message ? (Not a breaking change I presume.) |
@gkalpak yes we'll want it in the changelog, so a breaking change (I think we can let this one go since it was technically a bug, but if people depend on it they'll need to know) --- but also a snippet in the api docs would be good to clarify it |
Before #9757 and 1.3.6, filterFilter with string expression used to check object's properties recursively. Now it checks only object's top level properties, which is a breaking change to existing applications.
Here is a test that this pull request makes passable.