Skip to content
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

[IMP] base: _has_cycle replaces _check_recursion in SQL #162656

Closed

Conversation

HydrionBurst
Copy link
Contributor

@HydrionBurst HydrionBurst commented Apr 19, 2024

Implement the detection of cycles using a single recursive SQL query, for the sake of performance. The query starts from self.ids and follows the relation defined by the field. The good part is that we can use the same query for both many2many and many2one fields.

The new method _has_cycle() returns True if some records are reachable from self and are part of a cycle, even if those records are not part of self. This is acceptable, because this method is called after modifying some records, and we assume that the unchanged records did not contain a loop beforehand.

@robodoo
Copy link
Contributor

robodoo commented Apr 19, 2024

@C3POdoo C3POdoo requested review from a team, JulienVR, vlst-odoo, rco-odoo and ryv-odoo and removed request for a team April 19, 2024 15:10
@HydrionBurst
Copy link
Contributor Author

@kmagusiak since we have our naming convension for branch names I create a new PR for merging.
I also adapt the enterprise branch for you.

@C3POdoo C3POdoo added the RD research & development, internal work label Apr 19, 2024
@chevalierv chevalierv removed the request for review from a team April 25, 2024 11:19
@rco-odoo rco-odoo force-pushed the master-base-check-cycle-sql-cwg branch from 1f1302b to 284e87b Compare April 26, 2024 12:16
Implement the detection of cycles using a single recursive SQL query,
for the sake of performance.  The query starts from self.ids and follows
the relation defined by the field.  The good part is that we can use the
same query for both many2many and many2one fields.

The new method _has_cycle() returns True if some records are reachable
from self and are part of a cycle, even if those records are not part of
self.  This is acceptable, because this method is called after modifying
some records, and we assume that the unchanged records did not contain a
loop beforehand.
@rco-odoo rco-odoo force-pushed the master-base-check-cycle-sql-cwg branch from 284e87b to 8490bc2 Compare April 26, 2024 12:19
@rco-odoo
Copy link
Member

@robodoo r+

robodoo pushed a commit that referenced this pull request Apr 26, 2024
Implement the detection of cycles using a single recursive SQL query,
for the sake of performance.  The query starts from self.ids and follows
the relation defined by the field.  The good part is that we can use the
same query for both many2many and many2one fields.

The new method _has_cycle() returns True if some records are reachable
from self and are part of a cycle, even if those records are not part of
self.  This is acceptable, because this method is called after modifying
some records, and we assume that the unchanged records did not contain a
loop beforehand.

closes #162656

Related: odoo/enterprise#61159
Signed-off-by: Raphael Collet <rco@odoo.com>
@robodoo robodoo closed this Apr 26, 2024
@robodoo robodoo added the 17.3 label Apr 26, 2024
MohammedBasioni pushed a commit to odoo-dev/odoo that referenced this pull request May 6, 2024
Implement the detection of cycles using a single recursive SQL query,
for the sake of performance.  The query starts from self.ids and follows
the relation defined by the field.  The good part is that we can use the
same query for both many2many and many2one fields.

The new method _has_cycle() returns True if some records are reachable
from self and are part of a cycle, even if those records are not part of
self.  This is acceptable, because this method is called after modifying
some records, and we assume that the unchanged records did not contain a
loop beforehand.

closes odoo#162656

Related: odoo/enterprise#61159
Signed-off-by: Raphael Collet <rco@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
17.3 RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants