Bug #5800
Conversion issue with CAN-FIND
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:
0%
billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:
History
#1 Updated by Igor Skornyakov over 4 years ago
The conversion of the following program
def var ts1 as datetime no-undo. def var ts2 as datetime no-undo. FIND FIRST udftests WHERE udftests.test-name = '_minusts2' AND CAN-FIND(LAST udftests where udftests.fdatetime = ts1) = CAN-FIND(LAST udftests where udftests.fdatetime = ts2)
fails:
[javac] /media/ias/ssd1T/_gcdc/fwd/testcases/src/com/goldencode/testcases/udfs/T1.java:42: error: no suitable constructor found for FindQuery(Buf,String,<null>,String,logical,LockType)
[javac] (P2JQuery.Parameter) () -> isEqual(new FindQuery(udftests, "udftests.fdatetime = ?", null, "udftests.id asc", isEqual(udftests.getFdatetime(), ts1), LockType.NONE).hasAny(), new FindQuery(udftests, "udftests.fdatetime = ?", null, "udftests.id asc", isEqual(udftests.getFdatetime(), ts2), LockType.NONE).hasAny()),
[javac] ^
[javac] constructor FindQuery.FindQuery(DataModelObject,String,Supplier<logical>,String,DataModelObject,Object[]) is not applicable
[javac] (argument mismatch; logical cannot be converted to DataModelObject)
[javac] constructor FindQuery.FindQuery(DataModelObject,String,Supplier<logical>,String,DataModelObject,LockType) is not applicable
[javac] (argument mismatch; logical cannot be converted to DataModelObject)
[javac] constructor FindQuery.FindQuery(DataModelObject,String,Supplier<logical>,String,Object[],LockType) is not applicable
[javac] (argument mismatch; logical cannot be converted to Object[])
[javac] /media/ias/ssd1T/_gcdc/fwd/testcases/src/com/goldencode/testcases/udfs/T1.java:42: error: no suitable constructor found for FindQuery(Buf,String,<null>,String,logical,LockType)
[javac] (P2JQuery.Parameter) () -> isEqual(new FindQuery(udftests, "udftests.fdatetime = ?", null, "udftests.id asc", isEqual(udftests.getFdatetime(), ts1), LockType.NONE).hasAny(), new FindQuery(udftests, "udftests.fdatetime = ?", null, "udftests.id asc", isEqual(udftests.getFdatetime(), ts2), LockType.NONE).hasAny()),
[javac] ^
[javac] constructor FindQuery.FindQuery(DataModelObject,String,Supplier<logical>,String,DataModelObject,Object[]) is not applicable
[javac] (argument mismatch; logical cannot be converted to DataModelObject)
[javac] constructor FindQuery.FindQuery(DataModelObject,String,Supplier<logical>,String,DataModelObject,LockType) is not applicable
[javac] (argument mismatch; logical cannot be converted to DataModelObject)
[javac] constructor FindQuery.FindQuery(DataModelObject,String,Supplier<logical>,String,Object[],LockType) is not applicable
[javac] (argument mismatch; logical cannot be converted to Object[])
[javac] Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
[javac] 2 errors
4GL accepts the program as correct.
The converted code is:
public class T1
{
Udftests.Buf udftests = RecordBuffer.define(Udftests.Buf.class, "fwd", "udftests", "udftests");
@LegacySignature(type = Type.VARIABLE, name = "ts1")
datetime ts1 = TypeFactory.datetime();
@LegacySignature(type = Type.VARIABLE, name = "ts2")
datetime ts2 = TypeFactory.datetime();
/**
* External procedure (converted to Java from the 4GL source code
* in udfs/t1.p).
*/
@LegacySignature(type = Type.MAIN, name = "udfs/t1.p")
public void execute()
{
externalProcedure(T1.this, new Block((Body) () ->
{
RecordBuffer.openScope(udftests);
new FindQuery(udftests, "upper(udftests.testName) = '_MINUSTS2' and ?exists(from Udftests as udftests where udftests.fdatetime = ?)exists(from Udftests as udftests where udftests.fdatetime = ?)", null, "udftests.id asc", new Object[]
{
(P2JQuery.Parameter) () -> isEqual(new FindQuery(udftests, "udftests.fdatetime = ?", null, "udftests.id asc", isEqual(udftests.getFdatetime(), ts1), LockType.NONE).hasAny(), new FindQuery(udftests, "udftests.fdatetime = ?", null, "udftests.id asc", isEqual(udftests.getFdatetime(), ts2), LockType.NONE).hasAny()),
ts1,
ts2
}).addExternalBuffers(udftests, udftests).first();
}));
}
}
#2 Updated by Eric Faulhaber over 4 years ago
- Start date deleted (
11/02/2021)
The conversion has gone quite wrong. I don't think we've come across a case before which compares the results of two CAN-FINDs in a WHERE clause. The FindQuery should look something like this:
new FindQuery(udftests, "upper(udftests.testName) = '_MINUSTS2' and exists(from Udftests as udftests where udftests.fdatetime = ?) = exists(from Udftests as udftests where udftests.fdatetime = ?)", null, "udftests.id asc", new Object[]
{
ts1,
ts2
}).first();
#3 Updated by Igor Skornyakov over 4 years ago
Eric Faulhaber wrote:
The conversion has gone quite wrong. I don't think we've come across a case before which compares the results of two CAN-FINDs in a WHERE clause. The
FindQueryshould look something like this:[...]
Actually, if we compare the result of CAN-FIND with the value of a logical variable, we get similar error. Comparison with the value of a logical field is converted correctly.