Skip to main content
15-Moonstone
March 4, 2022
Solved

Primary Keys are Type Casting

  • March 4, 2022
  • 1 reply
  • 1048 views

So, I've had a problem with data table keys for a while now. When I set a number field as the primary key for a Data Shape and it gets used by a data table, the "key" field gets type-casted in a weird way. Whereas the data shape's field, say "Item", is filled with the number "10", the key field is stored as a string and the "Item" field gets type-casted that way and the resulting string ends up being "10.0". This results in problems when you try to search by the number "10", it will say that there is no such key. I've been programming around this problem, but I'm starting to get worried about future upgrades to ThingWorx causing problems for me. Is this going to be a problem for me in the future? Has it been fixed since ThingWorx 8.5? Is there a way to stop ThingWorx from adding the extra ".0"? Any help would be greatly appreciated.

Best answer by kazunari

Hi, how about using INTEGER for base type for you primary key?

1 reply

kazunari12-AmethystAnswer
12-Amethyst
March 11, 2022

Hi, how about using INTEGER for base type for you primary key?