Skip to content

fix(database): allow null values for equalTo, etc. - #715

Merged
katowulf merged 2 commits into
angular:masterfrom
cartant:issue-704
Dec 12, 2016
Merged

fix(database): allow null values for equalTo, etc.#715
katowulf merged 2 commits into
angular:masterfrom
cartant:issue-704

Conversation

@cartant

@cartant cartant commented Dec 10, 2016

Copy link
Copy Markdown
Contributor

Checklist

After following the steps in the contribution guide, the generated test-root.umd.js bundle was empty - apart from the boilerplate. This could have something to do with Windows being my OS. Hopefully, Travis will run the tests for me.

Description

This PR includes a refactor to rename a method that was considered to be misleading and a fix to allow the equalTo, startAt and endAt options for list queries to be null - as the current AngularFire2 behaviour differs from that of the underlying SDK (see the repro in the associated issue).

I've renamed the method to isNil - rather than the suggested isEmpty - as isNil is the name that's used in lodash (for an identical method) and using isEmpty would make the implementation of isEmptyObject too confusing:

export function isEmptyObject(obj: Object): boolean {
  // If the variable is considered empty, the object isn't? Huh?
  // What does empty mean?
  if (isEmpty(obj)) { return false; }
  return Object.keys(obj).length === 0 && JSON.stringify(obj) === JSON.stringify({});
}

isPresent is a misleading name (see angular#704) as it considers options
specified as null to not be present.
Values passed for equalTo, startAt and endAt should be allowed to be
null.

Closes angular#704.
@katowulf
katowulf merged commit 70a3e94 into angular:master Dec 12, 2016
@katowulf

Copy link
Copy Markdown
Contributor

🚀🚀🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants