在 Google App Engine 的 Python DataStore 模型中,get_by_key_name(<list_input>) 的结果是否与输入的顺序相同?
In Google App Engine's Python DataStore model, is the result of get_by_key_name(<list_input>) in the same order as the input?
以下代码通过键名批量获取实体列表:
key_names = [a, b, c, d, e]
result = models.SomeModel.get_by_key_name(key_names)
问题是:
我们能否安全地假设返回列表中实体的顺序始终与输入列表中键的顺序相同 (key_names)?
来自 Class Methods(强调我的):
Model.get_by_key_name (key_names, parent=None)
...
If key_names
consists of a single key name, this method returns the
model instance associated with the name if the name exists in the
Datastore, otherwise None
. If key_names
is a list, the return
value is a corresponding list of model instances, with None
values where no entity exists for a given key name.
我认为这是一个确认,我确实在我的代码中做出了这个假设至少到目前为止我没有遇到任何错误或其他 hint/indication 假设在某种程度上是不正确的。
以下代码通过键名批量获取实体列表:
key_names = [a, b, c, d, e] result = models.SomeModel.get_by_key_name(key_names)
问题是:
我们能否安全地假设返回列表中实体的顺序始终与输入列表中键的顺序相同 (key_names)?
来自 Class Methods(强调我的):
Model.get_by_key_name (key_names, parent=None)
...
If
key_names
consists of a single key name, this method returns the model instance associated with the name if the name exists in the Datastore, otherwiseNone
. Ifkey_names
is a list, the return value is a corresponding list of model instances, withNone
values where no entity exists for a given key name.
我认为这是一个确认,我确实在我的代码中做出了这个假设至少到目前为止我没有遇到任何错误或其他 hint/indication 假设在某种程度上是不正确的。