Reserved keywords, token labels and Find Slot

Reserved keywords, token labels and Find Slot

sean_tully
Contributor Contributor
337 Views
3 Replies
Message 1 of 4

Reserved keywords, token labels and Find Slot

sean_tully
Contributor
Contributor

I was recently having trouble getting an SQL query to work and there seems to be some undocumented behaviour when certain keywords are used in the query.

 

My query looked like this:

WHERE 
  slot.rackGroup == $1.rackGroup
  AND slot.hasSpace($1.pallet)
  AND (slot.slotSKU == $1.storageCode OR slot.slotSKU == "<none>")
  AND (slot.preferredType == $1.type OR slot.preferredType == "<none>")
ORDER BY
  (slot.slotSKU == $1.storageCode) DESC,
  (slot.preferredType == $1.type) DESC,
  slot.storageObject.name ASC,  
  slot.bayID ASC,
  slot.levelID ASC,
  slot.slotID ASC

 

The parameter $1 is a pointer to token.

 

I found that if I re-labelled token.type to token._type and used $1._type in the query above, it worked.

It seems as if the SQL query treats .type differently, as if it is some sort of reserved keyword.

Interestingly, the documentation for Find Slot actually uses $1.Type as an example, so it is just $1.type that gives trouble.

 

Is there any documentation that covers this?

Is there a list or guidance on what keywords should not be used as token labels?

 

0 Likes
Accepted solutions (1)
338 Views
3 Replies
Replies (3)
Message 2 of 4

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

"type" is a property of the Variant class, which is what the $1 would be seen as.

https://docs.flexsim.com/en/26.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Variant.html#...

To avoid running into this issue I generally always capitalize my label names, so they can't overlap with existing properties. For example, naming a label on an object "location" would also likely lead to issues, whereas "Location" is fine. The default names in Process Flow activities sadly set a bad example.

 

0 Likes
Message 3 of 4

sean_tully
Contributor
Contributor

Thanks, I think I will also take the defensive approach of explicitly casting things in the query e.g. $1.as(Token)._type.as(string).

0 Likes
Message 4 of 4

joerg_vogel_HsH
Mentor
Mentor

an under score Line is not a good advice either, because it is prestate to drag objects into a model and establish their automatic installed code. .  

 
 

 

 

0 Likes