Project

General

Profile

Bug #3267

same field referenced twice in a frame

Added by Greg Shah about 7 years ago. Updated about 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version:

History

#1 Updated by Greg Shah about 7 years ago

The following code causes duplication in the converted Java code:

form book.isbn isbn with frame ff2.

find first book.
display book.isbn isbn with frame ff2.

There are two references here to the same field, one is qualified and the other is not.

See testcases/uast/duplicated_field_reference.p. It depends on the test database, but probably can be recreated with temp-tables.

From Constantin:

This produces duplicate field references if DISPLAY book.isbn isbn is used, and also field-related metadata (like setTable and setDbname) are emitted twice in the FWD frame definition.

The problem is that in these cases the "name" annotation is emitted as "book.isbn" and "isbn" - is not the same, and the frame logic assumes the "name" annotation is unique.

This is somewhere deep in the SymbolResolver, where it produces a Variable instance with the name as specified at the node's text, and no disambiguation is done.

#3 Updated by Constantin Asofiei about 7 years ago

The problem is that we have duplicated code like this at the frame definition:

         isbn.setDbname("p2j_test");
         isbn.setTable("book");
         isbn.setDataType("character");
         isbn.setDbname("p2j_test");
         isbn.setTable("book");

and for this:
display tt1.f1 f1 with frame ff1.
display book.isbn isbn with frame ff2.

we get this:
         FrameElement[] elementList0 = new FrameElement[]
         {
            new Element(new FieldReference(tt1, "f1"), ff1Frame.widgetF1()),
            new Element(new FieldReference(tt1, "f1"), ff1Frame.widgetF1())
         };

         ff1Frame.display(elementList0);

         FrameElement[] elementList1 = new FrameElement[]
         {
            new Element(new FieldReference(book, "isbn"), ff2Frame.widgetIsbn()),
            new Element(new FieldReference(book, "isbn"), ff2Frame.widgetIsbn())
         };

         ff2Frame.display(elementList1);

#4 Updated by Greg Shah about 7 years ago

Do I understand correctly that there is no runtime error or problem? This is just a code duplication issue?

#5 Updated by Constantin Asofiei about 7 years ago

Greg Shah wrote:

Do I understand correctly that there is no runtime error or problem? This is just a code duplication issue?

Yes, I think is only a duplication issue. The runtime takes care of using only one widget ID, even if it appears multiple times.

I've just checked a case of form book.isbn book.isbn and the widget is still emitted twice.

As there is no runtime impact, we can defer this. Also, the behavior is the same for a simple var, in a case like DISPLAY i i - is emitted twice.

Also available in: Atom PDF