SR 86622 999 616 DimensionElementComponentAdd data loss
Posted: Wed Nov 11, 2009 9:09 pm
This was originally reported to Applix as issue 363783 but never resolved.
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.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.