Skip to content
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

UI - fix kv object so that falsey values don't get coerced to empty strings #4977

Merged
merged 2 commits into from
Jul 23, 2018

Conversation

meirish
Copy link
Contributor

@meirish meirish commented Jul 23, 2018

Currently on master, if you

  1. have an "advanced" (anything with non-string values) data structure for the kv backend
  2. any of those values are 0, false, or null,
  3. enter edit mode in the UI

You'll see that your false-y values get coerced to empty strings. This PR changes the kv object array proxy to check for existence of the value instead of checking its false-y-ness.

@meirish meirish requested review from a team July 23, 2018 20:45
@meirish meirish added this to the 0.10.4 milestone Jul 23, 2018
alisdair
alisdair previously approved these changes Jul 23, 2018
Copy link
Member

@alisdair alisdair left a comment

Choose a reason for hiding this comment

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

👍 Nice use of data table tests!

let expected = JSON.stringify(output, null, 2);
let data = KVObject.create({ content: [] }).fromJSON(input);
let result = data.toJSONString(includeBlanks);
assert.deepEqual(result, expected, 'has expected output string');
Copy link
Member

Choose a reason for hiding this comment

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

Unless I'm misreading this, we're comparing two strings here, so this can be assert.equal.

(I was initially concerned that comparing JSON.stringify output was invalid due to being non-deterministic, but that's not actually true!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yep - thanks!

@meirish meirish merged commit 42c767d into master Jul 23, 2018
@meirish meirish deleted the ui-json-edit-falsey branch July 23, 2018 21:57
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.

2 participants