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

Fix: [MIQ-2130] Issues with publisher when value is 0 #268

Merged
merged 3 commits into from
Nov 21, 2019

Conversation

shmsr
Copy link

@shmsr shmsr commented Nov 6, 2019

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

When '0' is published through a column, WHERE clause was dropped. Hence for 0, it wasn't working. For other numbers, it was working. After the fix, conversion to string is taken care of which fixes the error of not publishing when the value is 0.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@shmsr shmsr changed the title Fix issues with publisher when value is 0 Fix: [MIQ-2130] Issues with publisher when value is 0 Nov 6, 2019
@@ -54,7 +54,17 @@ const getFilter = (col, op, val) => {
}
}

const valueToString = (value) => value ? value.toString() : value;
const valueToString = (value) => {

Choose a reason for hiding this comment

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

Nice Catch

@@ -54,7 +54,17 @@ const getFilter = (col, op, val) => {
}
}

const valueToString = (value) => value ? value.toString() : value;
const valueToString = (value) => {
return value == null ? '' : (typeof value === 'object' && !value.toString ? '[object]' : String(value));

Choose a reason for hiding this comment

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

Suggested change
return value == null ? '' : (typeof value === 'object' && !value.toString ? '[object]' : String(value));
return value == null ? '' : (typeof value === 'object' && !value.toString ? '[TO_STRING_NOT_FOUND]' : String(value));

Copy link
Author

Choose a reason for hiding this comment

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

I've done some error reporting. Plus, I've tested it and the results seem fine.

This function hits the error handling function when we have the below as parameter:

  1. null
  2. Object.create(null) /* Prototype less object */

Choose a reason for hiding this comment

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

for null shouldn't this will be taken care by value == null

@@ -54,7 +54,22 @@ const getFilter = (col, op, val) => {
}
}

const valueToString = (value) => value ? value.toString() : value;
const valueToStringErr = (value) => {
console.log("Error: [Prototype-less object]/ [null] encountered for getEffectiveExtraFilters");

Choose a reason for hiding this comment

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

I am not sure syntax but there must be some way to use logger to log this at Info level

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I'll check.

}

const valueToString = (value) => {
return value == null ? valueToStringErr(value) : (typeof value === 'object' && !value.toString ? valueToStringErr(value) : String(value));

Choose a reason for hiding this comment

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

I think for null we can return same as existing code i.e null

valueToString = (value) => value ? value.toString() : value;

Copy link
Author

Choose a reason for hiding this comment

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

Sure.

@arpit-agarwal arpit-agarwal merged commit 0c27fce into master Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants