Search code examples
keyapp-engine-ndbdigitsauto-generate

Key-ids generated automatically on NDB on GAE


I found a statement about the title in a official documentation as below 1.

Here seems to say that auto-generated numeric number is 16 digits long at most.

Cloud Datastore can also automatically assign IDs. Cloud Datastore generates a random sequence of unused IDs that are approximately uniformly distributed. Each ID can be up to 16 decimal digits long.

Although saying above, according to my experiments, all auto-generated numeric number is FIX 16 digits. If the documentation is truely saying, is it better to take measures against attributing-bugs?

Anyone is welcome ,who has gotten an auto-generated id less than 15 digits long.


Solution

  • Cloud Datastore has a legacy id allocation policy which generally has lower numbers than 16 digit, though this is not guaranteed.

    In general, if you have requirements around the format of your Cloud Datastore ids, I would recommend developing your own id allocation policy (using string-based ids for your keys). This will let you make guarantees about what your ids look like.