Tryton - Issues

 

Issue7512

Title copy does not guarantee the order of returned records matches the order of the supplied ones
Priority bug Status testing
Superseder Nosy List albertca, ced, pokoli, reviewbot
Type behavior Components trytond
Assigned To ced Keywords review
Reviews 58291002
View: 58291002

Created on 2018-06-12.13:34:31 by albertca, last changed by reviewbot.

Messages
review58291002 updated at https://codereview.tryton.org/58291002/#ps60001
review58291002 updated at https://codereview.tryton.org/58291002/#ps40001
review58291002 updated at https://codereview.tryton.org/58291002/#ps20001
msg41568 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2018-06-21.11:15:39
Here is review58291002 with a test to ensure to keep this behavior.
msg41381 (view) Author: [hidden] (albertca) (Tryton committer) (Tryton translator) Date: 2018-06-12.13:34:30
ModelStorage.copy() method does not guarantee that the order of the records returned matches the order of the records supplied to the copy() method.

This is because the method returns a browse of a dictionary.values(), which is unordered [1]:

http://hg.tryton.org/trytond/file/tip/trytond/model/modelstorage.py#l365

That could be replaced with an OrderedDict.

Althought the documentation does not explicitly state that records will be returned in the same order [2], we expect that behaviour in some places such as [3].


[1] https://docs.python.org/2/library/stdtypes.html#dict.items
[2] http://doc.tryton.org/4.8/trytond/doc/ref/models/models.html?highlight=copy#trytond.model.ModelStorage.copy
[3] http://hg.tryton.org/modules/stock/file/tip/shipment.py#l2347
History
Date User Action Args
2018-06-21 15:01:23reviewbotsetmessages: + msg41575
2018-06-21 12:32:40reviewbotsetmessages: + msg41573
2018-06-21 11:26:06reviewbotsetnosy: + reviewbot
messages: + msg41570
2018-06-21 11:15:39cedsetstatus: unread -> testing
messages: + msg41568
keyword: + review
nosy: + ced
component: + trytond
reviews: 58291002
assignedto: ced
2018-06-12 13:46:07pokolisetnosy: + pokoli
2018-06-12 13:34:31albertcacreate

Showing 10 items. Show all history (warning: this could be VERY long)