私は次のオブジェクトをテストしています:
pk = ndb.Key(League, 'Premier League', 'Season', '2012/13')
o = Team(
id = 'Chelsea',
name ='Chelsea',
leagues = [
TeamInLeague(
parent = pk,
position = 1,
),],
)
o.put()
次のテストは失敗しますAssertionError: 0 != 1
:
q = Team.query(ancestor=pk)
self.assertEqual(q.count(), 1)
私も次のテストを試しました:
q = Team.query(TeamInLeague(ancestor=pk))
self.assertEqual(q.count(), 1)
そしてそれは失敗しAttributeError: type object 'TeamInLeague' has no attribute 'ancestor'
ます。
構造化プロパティの親でクエリを実行する方法はありますか?それとも私はそれをすべて間違っていますか?ドキュメントから、作成時に親プロパティを追加することがわかりました。