Page 1 of 1

SR 86622 999 616 DimensionElementComponentAdd data loss

Posted: Wed Nov 11, 2009 9:09 pm
by Alan Kirk
This was originally reported to Applix as issue 363783 but never resolved.
The problem can be replicated as follows:
- Create a new dimension with a single element.

- Use DimensionElementInsert to insert two new N level elements.
This will give you three N level elements in the dimension.

- In a second process, use DimensionElementInsert to try to insert one of the existing elements as a C level element.

This will cause no change to the dimension, but nor will it cause an error or a reject. The lack of a reject / error when the element is OF THE SAME TYPE is a good thing. It means that TI will just ignore any existing elements if you need to loop through a data source, adding all of the elements from that source. The lack of a reject / error where the type DIFFERS is more questionable since it's most likely to be caused by a programming error by the TI developer or an error in the source data. However it's still harmless as it makes no change to the dimension.

- In a third process, use DimensionElementComponentAdd to add one of your N level elements as a child of one of the other N level elements.

This will cause the other N level element to be converted from an N type to a consolidation, blowing away any data that had been entered against it.

I believe that it would be more desirable for an attempt to do that to generate an error, and for either:
(a) The programmer to have to delete the N level element and recreate it as a C level element rather than having DimensionElementComponentAdd do an implicit conversion; or
(b) Create functions which have to be explicitly called to do a conversion.

At the very least, the documentation should be changed to warn users that they could lose data if they accidentally add an element as a child of another N level element.
Edit: Although the old Forum didn't allow you to receive copies of your own e-mails the way more modern, sleek ones do, I found the e-mail from the posting that Curmudgeon made in the thread that's linked to above. The original report wasn't as long ago as I thought; 8 February 2008, apparently.

Re: SR 86622 999 616 DimensionElementComponentAdd data loss

Posted: Sat Nov 14, 2009 11:42 am
by Martin Ryan
Alan Kirk wrote: At the very least, the documentation should be changed to warn users that they could lose data if they accidentally add an element as a child of another N level element.
This would be my preferred solution. I use this "feature" quite a lot, import all elements as "N" level, regardless of whether they will continue to be N level and then stick children against them, so I'd find an error very annoying. I guess an alternative function that returns an error in this situation would be a useful compromise, but I wouldn't want the DimensionElementComponentAdd to error out in this instance.

Martin

Re: SR 86622 999 616 DimensionElementComponentAdd data loss

Posted: Sun Nov 15, 2009 11:20 pm
by Alan Kirk
Martin Ryan wrote:
Alan Kirk wrote: At the very least, the documentation should be changed to warn users that they could lose data if they accidentally add an element as a child of another N level element.
This would be my preferred solution. I use this "feature" quite a lot, import all elements as "N" level, regardless of whether they will continue to be N level and then stick children against them, so I'd find an error very annoying. I guess an alternative function that returns an error in this situation would be a useful compromise, but I wouldn't want the DimensionElementComponentAdd to error out in this instance.
OK, I've added your comments to the SR. My own feeling was based on the fact that this breaches the first commandment of any data system; "You shalt not trash your data nor cause it to be accidentally trashed". I'd rather be required to do an explicit conversion from N to C rather than run the risk that the code will do it for me without warning.

Re: SR 86622 999 616 DimensionElementComponentAdd data loss

Posted: Fri Jan 08, 2010 2:01 am
by Alan Kirk
From support:
I have now heard back from engineering on this defect but they have not yet had a chance to review. The feedback was that this was a P4 and was not a priorty.
It will therefore remain a case of "proceed with caution" when writing code that does this sort of thing.