The following code gets a list of entities in bulk by their key names:
key_names = [a, b, c, d, e] result = models.SomeModel.get_by_key_name(key_names)
The question is:
Can we safely assume that the order of the entities in the returned list is always the same as the order of keys in the input list (key_names)?
From Class Methods (emphasis mine):
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.
I considered that a confirmation and I did make that assumption in my code At least so far I didn't encounter any error or other hint/indication that the assumption would somehow be incorrect.