views:

176

answers:

2

After looking through the docs on App Engine and the StringListProperty or the ListProperty I can't seem to find whether there is a guarantee on the order of the items in the list. That is, I'd like to be certain that the list order stays the same despite putting and getting from the DataStore:

instance = MyModel()
instance.list_property = ['a', 'b', 'c']
instance.put()

# Retrieve the model again
instance2 = MyModel.get_by_id(instance.key().id())
assert instance2.list_property == ['a', 'b', 'c']

Does AppEngine make any guarantees about the order of items in a List or StringList?

+2  A: 

I can't find it explicitly said in the documentation, but according to a Google I/O talk about the DataStore, StringListProperty will be sorted the same way you put it there.

Lukáš Lalinský
+3  A: 

Yep, per the docs,

Order is preserved, so when entities are returned by queries and get(), list properties will have values in the same order as when they were stored.

It's the last sentence of the first paragraph at the URL I gave.

Alex Martelli