How is v# generated for the first time?


#1

My function created some instances of an entity type. Their v# are 65537. I was expecting the v# number to be 1 since these are newly created objects. How is v# generated?


#2

Does your type have any stored calc fields or is it AclEnabled? I believe these types of changes warrant an increment of the version number (and there are likely others).


#3

This may be of interest, though it does not exactly answer the question: https://en.wikipedia.org/wiki/65,537


#4

So the answer is that though the type lists the “version” field as an int, its actually a binary string.
The binary string for 65537 is: 10000000000000001 , or version 1.
(i’m not sure why there’s a ‘1’ character in the most significant bit, i think it means something specific)


#5

This is what @trothwein replied to a Q while back on platform-help

Q: In a Persistable type when is the version number initialized to 65537 or 131073 for an instance
A: The version number essentially stores 2 ints in one. the top half is for the version number used by calc fields, etc. The bottom half is the “user” version number. This is why you see numbers like this. If calc fields are ever refreshed for an obj, you will see something like that.