user1055761
user1055761

Reputation: 1071

Will accessing a Reference'd Entity cause a 'get()' for an already fetched Entity?

class Parent:
    name = db.StringProperty()

class Child
    parent = db.ReferenceProperty (reference_class=Parent)

p = Parent.get()

q = Child.all()
q.filter ("parent =", p.key())
children = q.fetch(100)
children[0].parent.name # will this cause another call to get() on Parent ?

In the above example, will the accessing the parent.name attribute on one of the children cause a parent to be re-fetched - or all children's parent is point to 'p' ?

Hope this clear and appreciate any help..

Thanks.

Upvotes: 0

Views: 25

Answers (1)

Tim Hoffman
Tim Hoffman

Reputation: 12986

Yes it will cause the parent to be refetched.

There is no implicit caching when using db.

ndb which does have caching, would potentially fetch the parent as you don't have a reference property and you need to perform an explicit get on a KeyProperty.

Upvotes: 2

Related Questions