Skip to content

[ADD] validate_fk_constraints function#382

Open
thomaspaulb wants to merge 1 commit intoOCA:masterfrom
sunflowerit:validate-fk-constraints
Open

[ADD] validate_fk_constraints function#382
thomaspaulb wants to merge 1 commit intoOCA:masterfrom
sunflowerit:validate-fk-constraints

Conversation

@thomaspaulb
Copy link

This is useful in cases where you need to delete a lot of records, and you speed the deletion up by disabling FK triggers, but you want to validate integrity after deletion.

Sample use:

env.cr.execute('alter table res_partner disable trigger all')
env.cr.execute(delete from res_partner where id = 738152')
validate_fk_constraints(env.cr, 'res_partner', 'id')
# of course this will fail, so then you can iterate until referential integrity is achieved again

This is useful in cases where you need to delete a lot of records,
and you speed the deletion up by disabling FK triggers,
but you want to validate integrity after deletion.
@thomaspaulb thomaspaulb force-pushed the validate-fk-constraints branch from eee2e40 to 19422d0 Compare September 26, 2024 10:14
logger.warning("Failed to clean transient table %s\n%s", table_name, str(e))


VALIDATE_FK_QUERY = """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why outside of validate_fk_constraints? I would put inside...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants