[FIX] Incorrect table alias used in joins #13150
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the issue/feature this PR addresses:
This PR contains the part of #1760 which has not been merged yet.
Current behavior before PR:
Suppose you have models with long names
long.a
andlong.b
wherelong.b
inherits fromlong.a
by_inherits
. Then Odoo will generate the alias by joining the table names by two underscores. When the name exceeds the 64 character limit of PostgreSQL, Odoo will use a hash-based alias to stay within the limit. However, when preparing joins this alias is not used, which leads to broken SQLIn this case
verylongtable111__verylongtable2222222222222_id__verylongtable3333_id
is unknown to PostgreSQL. The alias should be used instead.Desired behavior after PR is merged:
The correct table alias is used in all circumstances.
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr