0
votes

I am dealing with a google app engine application based on ndb and two entities (A and B) where A has a one to many relationship with B implemented with a property like this

bobjects = ndb.KeyProperty(repeated=True);

I have created one A object (say a1) and three B objects (b1,b2,b3). I have therefore add the b1,b2 and b3 keys to the a1.objects vector. It works fine but I have therefore deleted b1,b2 and b3 from the datastore and they are still visibile in a1 (!). why?

2

2 Answers

1
votes

Why would they not be?

A KeyProperty stores keys. There's nothing to say those have to be keys to entities that actually exist, or even keys referring to entity types you have even defined. They're just keys.

GAE is not a relational database, and you should not treat it as one. If you need to keep references to other entities, you'll need to be sure you update those references yourself when necessary.

0
votes

Think of your filesystem's shortcuts/symlinks.

When you create a shortcut/symlink to a file and then delete the original file - the shortcut/symlink still remains on the filesystem pointing to something that does not exist anymore.

It would be too expensive for the filesystem to keep track of every shortcut/symlink ever created and delete them if the destination was removed.