1)当我执行这个查询时:
contract_record = Contract(book_number = 42, initial_page = 420, final_page = 442)
contract_record.put()
contract_key = contract_record.key()
contract = db.GqlQuery("SELECT * FROM Contract WHERE __key__ = KEY('Contract', '$[contract_key]')").get()
结果是无。为什么?
2)如何通过key_id而不是key进行查询?(像这样:
contract_id = contract_record.key().id()
contract = db.GqlQuery("SELECT * FROM Contract WHERE __key__ = KEY('Contract', '$[contract_id]')").get()
谢谢你的帮助!