備忘録

物忘れが酷いので

google-cloud-datastore<=0.20からgoogle-cloud-datastore>=0.21へアップデートするときの応急処置

google-cloud-datastore>=0.21にアップデートするとdatastoreのQuery.fetch().next_page()がプライベートメソッドになっている.
そのため,以下のように書き換えることで,アップデートに対応できる.

lst, has_next, cursor = query.fetch(start_cursor=cursor).next_page()

から

itr = query.fetch(start_cursor=cursor)
lst, has_next, cursor = list(next(itr.pages)), itr.next_page_token != cursor, itr.next_page_token

とすることで,応急処置できる.