Ever see duplicate IDs when using Google App Engine and ndb?

爷,独闯天下 提交于 2020-01-04 04:25:06

问题


class Entries(ndb.Model):
  description = ndb.StringProperty()
  seqid = ndb.IntegerProperty()
  link = ndb.StringProperty()
  group = ndb.StringProperty()
  timestamp = ndb.StringProperty()
  referrals = ndb.StringProperty(repeated=True)

The two entries in the picture are created by two different users. The user is the parent of the Entry.

I get a duplicate ID on production but not on local. Also, it's always this same id number (but it is certainly not hard coded anywhere)

As the parent is the user, i can still pull it as a unique entry but it will mean there will be problems if I have two entries with the same parent user.


回答1:


A datastore's unique key is the fully qualified key, including all parent entity keys, not just the ID. Multiple entities with the same ID and different parents are completely valid, and you shouldn't rely on the id alone being unique.



来源:https://stackoverflow.com/questions/27531010/ever-see-duplicate-ids-when-using-google-app-engine-and-ndb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!