You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hop.apache.org by "gmitter-ef (via GitHub)" <gi...@apache.org> on 2023/05/09 10:32:24 UTC

[GitHub] [hop] gmitter-ef opened a new issue, #2909: Different behaviour of JavaScript step on boolean variables depending on source

gmitter-ef opened a new issue, #2909:
URL: https://github.com/apache/hop/issues/2909

   ### Apache Hop version?
   
   2.3
   
   ### Java version?
   
   OpenJDK 11
   
   ### Operating system
   
   Windows
   
   ### What happened?
   
   Look at the attached pipeline.
   
   Problem 1:
   
   when a Boolean stream field is passed to "Modified JavaScript value" step, the comparison for "true" only seems to be done correctly using "== true", but not using the bool variable itself. See 1.a).
   (1.b) is a result of 1.b) and can be ignored at first I think)
   
   When the bool is a JavaScript variable from the beginning (created via "var"), the condition works in both variants. See also 3).
   
   Problem 2:
   
   The comparison of two Integer stream fields via "!=" directly does not work correctly.
   When using Math.ceil on the Integers, however, the comparison works.
   Furthermore, it does work correctly when the integers are JavaScript variables from the beginning.
   
   See attached pipeline and notes for exact reproduction and comparison with regard to what would be expected vs. observed output.
   [test.zip](https://github.com/apache/hop/files/11430183/test.zip)
   
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: Transforms


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hop] gmitter-ef commented on issue #2909: Different behaviour of JavaScript step on boolean variables depending on source

Posted by "gmitter-ef (via GitHub)" <gi...@apache.org>.
gmitter-ef commented on issue #2909:
URL: https://github.com/apache/hop/issues/2909#issuecomment-1547281660

   Thanks for the comment! Actually, in my case I think I have verified that the stream fields are NOT null, and still the comparisons behave as described.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hop] bjackson-ep commented on issue #2909: Different behaviour of JavaScript step on boolean variables depending on source

Posted by "bjackson-ep (via GitHub)" <gi...@apache.org>.
bjackson-ep commented on issue #2909:
URL: https://github.com/apache/hop/issues/2909#issuecomment-1554592042

   In order to test your findings, we would first test for null, right?  Then do the .valueOf() function upon that object, otherwise I think the step will fail with some address. (no functions exist on null).  I will try this out.  I appreciate having a sounding board.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Different behaviour of JavaScript step on boolean variables depending on source (hop)

Posted by "gmitter-ef (via GitHub)" <gi...@apache.org>.
gmitter-ef commented on issue #2909:
URL: https://github.com/apache/hop/issues/2909#issuecomment-5474248732

   Great, thx for fixing it, the explanation in the docs is really helpful now.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hop] gmitter-ef commented on issue #2909: Different behaviour of JavaScript step on boolean variables depending on source

Posted by "gmitter-ef (via GitHub)" <gi...@apache.org>.
gmitter-ef commented on issue #2909:
URL: https://github.com/apache/hop/issues/2909#issuecomment-1554419816

   Using ".valueOf()" on the variables coming from the stream shows correct (expected) behaviour both the bool problem (1) and the integer comparison (problem 2).
   Still the behaviour should not be the way it is without this function call, I believe at least.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hop] gmitter-ef commented on issue #2909: Different behaviour of JavaScript step on boolean variables depending on source

Posted by "gmitter-ef (via GitHub)" <gi...@apache.org>.
gmitter-ef commented on issue #2909:
URL: https://github.com/apache/hop/issues/2909#issuecomment-1551260254

   For problem2, found out that typeof(...) Javascript operator yields "object" for the integers coming from the stream, but "number" for the integers declared directly in JavaScript.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Different behaviour of JavaScript step on boolean variables depending on source (hop)

Posted by "hansva (via GitHub)" <gi...@apache.org>.
hansva closed issue #2909: Different behaviour of JavaScript step on boolean variables depending on source
URL: https://github.com/apache/hop/issues/2909


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Different behaviour of JavaScript step on boolean variables depending on source (hop)

Posted by "mattcasters (via GitHub)" <gi...@apache.org>.
mattcasters commented on issue #2909:
URL: https://github.com/apache/hop/issues/2909#issuecomment-1813311805

   So yes, Hop uses a Java Boolean value to represent these values.  The Rhino JavaScript engine understands `boolean` so using `field.valueOf()` performs this conversion.  I would suggest to add a section on Boolean values in the JavaScript transform documentation. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hop] bjackson-ep commented on issue #2909: Different behaviour of JavaScript step on boolean variables depending on source

Posted by "bjackson-ep (via GitHub)" <gi...@apache.org>.
bjackson-ep commented on issue #2909:
URL: https://github.com/apache/hop/issues/2909#issuecomment-1546791904

   I also had an issue with booleans and comparison operators.  Java booleans are not allowed to be null but must take a value, however Hop allows a field to be True, Null, or False, at least in the preview panel.  I think what is happening in my case is a null comes in and the comparison fails.   Maybe the Javascript step should get a helper function to allow the user to test what state the incoming field is in, especially for nulls.  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Different behaviour of JavaScript step on boolean variables depending on source (hop)

Posted by "sramazzina (via GitHub)" <gi...@apache.org>.
sramazzina commented on issue #2909:
URL: https://github.com/apache/hop/issues/2909#issuecomment-5457748954

   .take-issue
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org