Identifying Unique Attributes in STK 4.1

Hi there,
In STK 4.1, the method Record.copy_to() was introduced, but I quickly realised that it's quite useless if there are any unique attributes defined in the table, as the copy action fails due to the illegal doubled values. In the past, I created an own copy-function in which I used Record.definition._attribute_detail.isUnique in order to get rid of such attributes. However, this seems to be gone in 4.1.
Is there either a way to tune up the Record.copy_to() method in 4.1 or a similar function like Record.definition._attribute_detail.isUnique that can be used for such a use case?
Thanks in advance & best,
Daniel
Best Answer
-
Hi Daniel!
Two items here:
- The
isUnique
property is a foundation-layer property which we haven't previously exposed in the streamlined layer. With v4.0 and before it was possible to access the underlying object via the private attribute_attribute_detail
as you have done, but the way we construct streamlined layer objects has changed with v4.1, and this object is no longer available. I will try to add this property into the upcoming v4.2 release, but the timing is very tight, so I cannot promise anything.
To access this information using v4.1, you would need to use the foundation layer directly.
In general, I'd advise against using private attributes with an underscore prefix for exactly this reason. We avoid making breaking changes to the public API between minor versions without first deprecating the functionality, but private classes/methods/attributes with underscore prefixes are not considered part of the stable API and so may change with any release. If there are any others you are using, please let us know and we'll see if we can add them to the public API.
- We plan to improve the copy_to() function to make it more flexible in a future release. The exact implementation is still TBD, but we plan to make it possible to choose which attributes to copy across, and it might also make sense to avoid coping attributes marked as unique as standard functionality.
0 - The
Answers
-
Hi Andy,
thanks as always for your quick response!
Yeah, I'm quite aware that it's bad practice to use private attributes - but well, it was a great workaround
But I already expected that answer g But great to read you having that in your backlog!
Actually, this one was to only private attribute I misused. But it would be great if you could provide a hint how to access the isUnique property via the foundation layer, as I'm still not really familiar with it.
Depending on how complicate this is, I'd stick with STK 4.0 or not.Thanks again & best,
Daniel0 -
I'd hold off on the foundation layer approach for now. Hopefully we'll be able to get this into the upcoming release, but if not, I'd recommend using 4.0 instead.
0 -
You're probably right
I'll just leave it as it is and hope the best for the upcoming release
Thanks & best,
Daniel0