I'm using 10.2B08. Upgrade to v.11 is not an option.
My problem is that dataset's READ-JSON() leaves grandparent's key blank.
The issue occurs only when data-relations have attributes NESTED and FOREIGN-KEY-HIDDEN.
I wouldn't like to drop them out because in my real dataset the foreign keys occupy a lot of space, and my intention is to pass the data on the appserver with async call.
Here is example:
/* TT and Dataset definition */
DEFINE TEMP-TABLE TParent
FIELD ParentKey AS CHAR
index xpk IS PRIMARY UNIQUE
ParentKey.
DEFINE TEMP-TABLE TChild
FIELD ParentKey AS CHAR
FIELD ChildKey AS CHAR
index xpk IS PRIMARY UNIQUE
ParentKey
ChildKey.
DEFINE TEMP-TABLE TGChild
FIELD ParentKey AS CHAR
FIELD ChildKey AS CHAR
FIELD GChildKey AS CHAR
index xpk IS PRIMARY UNIQUE
ParentKey
ChildKey
GChildKey.
DEFINE DATASET ds1 FOR TParent, TChild, TGChild
DATA-RELATION PARENT_Child FOR TParent, TChild NESTED FOREIGN-KEY-HIDDEN
RELATION-FIELDS (ParentKey, ParentKey)
DATA-RELATION Child_GChild FOR TChild, TGChild NESTED FOREIGN-KEY-HIDDEN
RELATION-FIELDS (ParentKey, ParentKey, ChildKey, ChildKey).
/* Fill dataset with sample data.
There are two parent records. Each of them has two children.
Each of the children has two grandchildren. */
CREATE TParent. ASSIGN TParent.ParentKey = "parent1".
CREATE TChild. ASSIGN TChild.ParentKey = "parent1" TChild.ChildKey = "child11".
CREATE TGChild. ASSIGN TGChild.ParentKey = "parent1" TGChild.ChildKey = "child11" TGChild.GChildKey = "Gchild111".
CREATE TGChild. ASSIGN TGChild.ParentKey = "parent1" TGChild.ChildKey = "child11" TGChild.GChildKey = "Gchild112".
CREATE TChild. ASSIGN TChild.ParentKey = "parent1" TChild.ChildKey = "child12".
CREATE TGChild. ASSIGN TGChild.ParentKey = "parent1" TGChild.ChildKey = "child12" TGChild.GChildKey = "Gchild121".
CREATE TGChild. ASSIGN TGChild.ParentKey = "parent1" TGChild.ChildKey = "child12" TGChild.GChildKey = "Gchild122".
CREATE TParent. ASSIGN TParent.ParentKey = "parent2".
CREATE TChild. ASSIGN TChild.ParentKey = "parent2" TChild.ChildKey = "child21".
CREATE TGChild. ASSIGN TGChild.ParentKey = "parent2" TGChild.ChildKey = "child21" TGChild.GChildKey = "Gchild211".
CREATE TGChild. ASSIGN TGChild.ParentKey = "parent2" TGChild.ChildKey = "child21" TGChild.GChildKey = "Gchild212".
CREATE TChild. ASSIGN TChild.ParentKey = "parent2" TChild.ChildKey = "child22".
CREATE TGChild. ASSIGN TGChild.ParentKey = "parent2" TGChild.ChildKey = "child22" TGChild.GChildKey = "Gchild221".
CREATE TGChild. ASSIGN TGChild.ParentKey = "parent2" TGChild.ChildKey = "child22" TGChild.GChildKey = "Gchild222".
/* All 8 records are OK */
FOR EACH TGChild: DISPLAY TGChild. END.
/* Put the dataset's content into json file and then re-read it. */
DATASET ds1:WRITE-JSON("file", "./ds1.json", TRUE).
DATASET ds1:EMPTY-DATASET().
DATASET ds1:READ-JSON("file", "./ds1.json").
/* Now the ParentKey is empty in all records. */
FOR EACH TGChild: DISPLAY TGChild. END.
This bug exists in 11.0 through 11.7 as well. You should log a bug with Tech Support. I'm not sure what qualifies for a 10.2B hotfix.
This bug exists in 11.0 through 11.7 as well. You should log a bug with Tech Support. I'm not sure what qualifies for a 10.2B hotfix.