-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
@@ -54,7 +54,17 @@ const getFilter = (col, op, val) => { | |||
} | |||
} | |||
|
|||
const valueToString = (value) => value ? value.toString() : value; | |||
const valueToString = (value) => { |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)); |
There was a problem hiding this comment.
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:
- null
- Object.create(null) /* Prototype less object */
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
CATEGORY
Choose one
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
REVIEWERS