Tryton - Issues

 

Issue7512

Title copy does not guarantee the order of returned records matches the order of the supplied ones
Priority bug Status resolved
Superseder Nosy List albertca, ced, pokoli, reviewbot, roundup-bot
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 roundup-bot.

Messages
New changeset a5932fc4acdd by Cédric Krier in branch '4.8':
Return new records from copy following the input order
https://hg.tryton.org/trytond/rev/a5932fc4acdd

New changeset dc25bfa843ae by Cédric Krier in branch '4.6':
Return new records from copy following the input order
https://hg.tryton.org/trytond/rev/dc25bfa843ae

New changeset 54bf6df80a25 by Cédric Krier in branch '4.4':
Return new records from copy following the input order
https://hg.tryton.org/trytond/rev/54bf6df80a25

New changeset 43b119087bd4 by Cédric Krier in branch '4.2':
Return new records from copy following the input order
https://hg.tryton.org/trytond/rev/43b119087bd4

New changeset 0f8edc2c1a06 by Cédric Krier in branch '4.0':
Return new records from copy following the input order
https://hg.tryton.org/trytond/rev/0f8edc2c1a06
New changeset 2235dea49f09 by Cédric Krier in branch 'default':
Return new records from copy following the input order
https://hg.tryton.org/trytond/rev/2235dea49f09
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-29 11:31:32roundup-botsetmessages: + msg41973
2018-06-24 16:48:33roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg41622
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)