Bug 6653

Different Expression Results 11 June, 2021

Gregory Rusak
21 May, 2021
Product: PowerBuilder Category: DataWindow
Version: 2019 R2 Build: 2328
Classification: Issue Publishing: Public
Priority: P3
Status: Verifying Reason:
Communication Status: Waiting for Customer
Kai Zhao @Appeon 11 June, 2021
#7
Hi Greg,

I'm just touching base with you about this ticket.  

Did we provide you with enough information to resolve this issue?
Please let us know if there is something else to support you with.  

Regards,
ZhaoKai
Kai Zhao @Appeon 04 June, 2021
#6
Hi Greg,

I would like to check with you if the response provided has been helpful enough
to resolve your case. If so, can we proceed to close the ticket?
Otherwise, do let us know if we can provide you with any further assistance and
keep in mind that you are always welcome to open another ticket in case you
need it.

Regards,
ZhaoKai
Kai Zhao @Appeon 24 May, 2021
#5
Hi Greg,

Yes. The same expression might get different results returned in PowerScript and DataWindow, so you need to treat them differently.

The root cause is that the operator precedence in DataWindow expressions is different from that in PowerBuilder expressions. Please refer to online help for more details.
https://docs.appeon.com/pb2019r3/datawindow_reference/ch01s03.html
https://docs.appeon.com/pb2019r3/powerscript_reference/ch01s04s02.html

Regards,
ZhaoKai
Gregory Rusak 24 May, 2021
#4
Thank you Kai,

Very interesting.

So to note then, the following PowerScript returns a different Boolean result:

IF NOT (1 = 1) AND (1 = 2) THEN
                MessageBox("Test", "TRUE")
ELSE
                MessageBox("Test", "FALSE")
END IF

So we are to treat the order of precedence differently in Expressions than PowerScript? Is that correct ?

Kind Regards,

Greg
Kai Zhao @Appeon 24 May, 2021
#3
Hi Greg,

Thanks for providing the DWO source. I reproduced the issue on our end, and PB 12.6 has the same behavior.

The root cause of the issue is the precedence of the operator 'not' is lower than operator 'and' in DataWindow expressions, it is different from that in PowerBuilder expressions. Please refer to online help for more details.
https://docs.appeon.com/pb2019r3/datawindow_reference/ch01s03.html
https://docs.appeon.com/pb2019r3/powerscript_reference/ch01s04s02.html

To override the order, please enclose expressions in parentheses, for your case, please change script 
from
IF(NOT (1=1) AND (1 = 2), 1, 0)
to
IF((NOT 1=1) AND (1 = 2), 1, 0)

Regards,
ZhaoKa
Chris Pollach @Appeon 21 May, 2021
#2
Hi Greg;

  Thank you for opening this ticket and submitting the DWO source for this issue.

  I will now transfer this ticket over to the main Support / Engineering team for their review & feedback.

Regards ... Chris
Gregory Rusak 21 May, 2021
#1
d_test.zip (1KB)

*Phenomenon:
We're experiencing an odd issue with computed expressions, specifically the following.

Why does this expression equate to 1:

IF(NOT (1=1) AND (1 = 2), 1, 0)

While this expression correctly equates to 0:

IF( (1 = 2) AND NOT (1=1), 1, 0)

If anyone can shed some light, that would be greatly appreciated.

*Reproduce Steps:
See attached exported datawindow for an example.

Remarks:
Chris has asked for this to be submitted.
OS:
Windows 10
Platform:
32-bit
Database Type:
SAP SQL Anywhere
Database Version:
17