Skip to content

findOrDefaultIfNull issue #701

@Martii

Description

@Martii

I really think this exported function is bugged… or at the very least incomplete with non-descriptive function naming...

Consider this abbreviated snippet:

options.byModel = aReq.query.byModel !== undefined ? aReq.query.byModel : null;

var removedItemListQuery = Remove.find();

modelQuery.findOrDefaultIfNull(removedItemListQuery, 'model', options.byModel, null);

… should probably just return from the function… instead it does a filter on the list with these conditions:

[ { model: null }, { model: null } ]

… and if I actually choose a default of something, say 'User' for findOrDefaultIfNull, it returns this for this condition:

[ { model: null } ]

… in other words the default is never done at all.

What, in human terms, is the function here supposed to really do? I understand it is supposed to filter but it doesn’t appear to be doing that anywhere e.g. the first line of the snippet will always set something, whether it be false or some other value.

This issue is mainly targetted at @Zren since he did it at 7875f52 but anyone can pipe in to improve the understanding.

TIA

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugYou've guessed it... this means a bug is reported.enhancementSomething we do have implemented already but needs improvement upon to the best of knowledge.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions