Skip to content

Conversation

@laurenzlong
Copy link
Contributor

Description

Fix bug where event.data.val() was returning array of nulls when database payload had a length property.

Code sample

If new database node looks like:
{ length: "something", foo: "bar"}

Previously, calling event.data.val() would return array of nulls (since lodash's _.forEach method thought that the data was actually an array due to the presence of the length property, and tried to iterate over teh nonexistent array elements). Now, event.data.val() will return the expected value of { length: "something", foo: "bar"}

expect(subject.val()).to.deep.equal({ myOtherKey: 'bar' });
});

// Regression test: .val() was returning array of nulls when there's a property called length
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add "BUG(37683995)" in this comment, for our future reference if we want to remember more details?

} else {
allIntegerKeys = false;
for (let key in node) {
if (node.hasOwnProperty(key)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove a level of indentation for the code below, by using:
if (!node.hasOwnProperty(key)) { continue; }

@laurenzlong
Copy link
Contributor Author

@rjhuijsman done! Thanks for the tip!

@laurenzlong laurenzlong merged commit 37e994a into master May 3, 2017
@laurenzlong laurenzlong deleted the ll-dbnull branch May 3, 2017 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants