-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] records: use temp table in replacing refs #224
base: master
Are you sure you want to change the base?
Conversation
upgradeci retry with always only documents_project_sale in version 18.0 |
What examples do we have of such issue? Isn't this a problem of the caller to replace_records_reference_batch? Or that we should implement something perhaps splitting the id mapping? |
i saw this so far only in documents upgrade when replacing folders with documents here |
cd641d9
to
de159d9
Compare
Can you add a test? |
de159d9
to
7bdd490
Compare
The test depends on odoo/odoo#200509 |
7bdd490
to
324ea17
Compare
324ea17
to
65d35c3
Compare
the community PR is merged and the test is now green |
65d35c3
to
44c3584
Compare
src/base/tests/test_util.py
Outdated
add_test_trigger(self.env.cr, "replace_record_references", "res_partner", "UPDATE", f"new.id = {p3.id}") | ||
util.replace_record_references_batch(self.env.cr, mapping, "res.currency") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be context manager
add_test_trigger(self.env.cr, "replace_record_references", "res_partner", "UPDATE", f"new.id = {p3.id}") | |
util.replace_record_references_batch(self.env.cr, mapping, "res.currency") | |
with self.assertNotUpdated("res_partner", [p3.id]): | |
util.replace_record_references_batch(self.env.cr, mapping, "res.currency") |
Signature: def assertNotUpdated(self, table, ids=None):
.
When ids is None, the whole should be handled, which mean no INSERT
.
We can also add the positive version def assertUpdated(self, table, ids=None)
These functions need to be added in a dedicated commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with the other assertX
functions, the signature needs to take a msg
argument.
assertNotUpdated(self, table, ids=None, msg=None)
Two contextmanager methods added to UnitTestCase to assert wether records in the database are updated or not. The assert requires a table name and an optional list of ids. If ids are provided, those specific records will be checked if updated or not. If no ids are provided then the validation will be based on the insert or update of any record of that relation.
For the jsonb company dependent indirect references when replacing record refs, building the query using the original id mapping input can generate a large query based on the number of references being updated, leading to a 'stack depth limit exceeded' error. We can use the mapping saved in the temp table _upgrade_rrr instead.
44c3584
to
8ab406a
Compare
For the jsonb company dependent indirect references when replacing record refs, building the query using the original id mapping input can generate a large query based on the number of references being updated, leading to a
stack depth limit exceeded
error.We can use the mapping saved in the temp table
_upgrade_rrr
instead.TBG-1752