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] core: DatabaseObject replaces _sql_constraints #11071

Closed
wants to merge 1 commit into from

Conversation

kmagusiak
Copy link
Contributor

@kmagusiak kmagusiak commented Sep 23, 2024

task-3390431

odoo/odoo#175783

@robodoo
Copy link
Collaborator

robodoo commented Sep 23, 2024

Pull request status dashboard

@kmagusiak kmagusiak force-pushed the master-sql-constraints-object-krma branch 2 times, most recently from ce2df4e to 92c9d1c Compare September 24, 2024 01:59
@kmagusiak kmagusiak force-pushed the master-sql-constraints-object-krma branch 4 times, most recently from 346a051 to e12c47d Compare October 11, 2024 08:03
content/contributing/development/coding_guidelines.rst Outdated Show resolved Hide resolved
content/developer/reference/backend/orm.rst Outdated Show resolved Hide resolved
content/developer/reference/backend/orm.rst Outdated Show resolved Hide resolved
content/developer/reference/backend/orm.rst Outdated Show resolved Hide resolved
content/developer/reference/backend/orm.rst Outdated Show resolved Hide resolved
@kmagusiak kmagusiak force-pushed the master-sql-constraints-object-krma branch from e12c47d to b1985ee Compare October 17, 2024 09:28
@kmagusiak kmagusiak marked this pull request as ready for review October 17, 2024 09:29
@C3POdoo C3POdoo requested review from a team and HydrionBurst and removed request for a team October 17, 2024 09:31
content/developer/reference/backend/orm.rst Outdated Show resolved Hide resolved
content/contributing/development/coding_guidelines.rst Outdated Show resolved Hide resolved
content/developer/howtos/translations.rst Show resolved Hide resolved
content/developer/reference/backend/orm.rst Outdated Show resolved Hide resolved
content/developer/reference/backend/orm.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@AntoineVDV AntoineVDV left a comment

Choose a reason for hiding this comment

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

@robodoo delegate+

content/developer/reference/backend/orm.rst Outdated Show resolved Hide resolved
@kmagusiak kmagusiak force-pushed the master-sql-constraints-object-krma branch 2 times, most recently from 6795a40 to 9b7ef93 Compare October 18, 2024 11:17
@kmagusiak kmagusiak changed the title [IMP] core: SQLObject replaces _sql_constraints [IMP] core: DatabaseObject replaces _sql_constraints Oct 18, 2024
@kmagusiak kmagusiak force-pushed the master-sql-constraints-object-krma branch 3 times, most recently from 637d6ac to 7547432 Compare October 24, 2024 08:06
@kmagusiak
Copy link
Contributor Author

@robodoo r+

@robodoo
Copy link
Collaborator

robodoo commented Oct 24, 2024

@kmagusiak linked pull request(s) odoo/enterprise#68589, odoo/odoo#175783 not ready. Linked PRs are not staged until all of them are ready.

@kmagusiak kmagusiak force-pushed the master-sql-constraints-object-krma branch from 7547432 to dd1eb38 Compare October 25, 2024 06:55
@kmagusiak kmagusiak force-pushed the master-sql-constraints-object-krma branch from dd1eb38 to 97b46d5 Compare October 29, 2024 09:49
@kmagusiak kmagusiak force-pushed the master-sql-constraints-object-krma branch from 97b46d5 to c42cb92 Compare November 5, 2024 11:26
@kmagusiak kmagusiak force-pushed the master-sql-constraints-object-krma branch from c42cb92 to e9c7b77 Compare November 7, 2024 13:37
@kmagusiak
Copy link
Contributor Author

@robodoo r+

@robodoo
Copy link
Collaborator

robodoo commented Nov 7, 2024

@kmagusiak you may want to rebuild or fix this PR as it has failed CI.

robodoo pushed a commit to odoo/odoo that referenced this pull request Nov 8, 2024
Edition of the constraints is not reflected in the database.
The only thing you can do is to remove them and set the message.

Part-of: #175783
Related: odoo/enterprise#68589
Related: odoo/documentation#11071
Signed-off-by: Raphael Collet <[email protected]>
robodoo pushed a commit to odoo/odoo that referenced this pull request Nov 8, 2024
Introducting `models.Constraint` that will replace `_sql_constraints`.
We make the message extensible since you ow have access to the
diagnostics and can make them dynamic. The messages between the web
interface and the imports are also aligned.

Constraints are generalized as TableObjects and can be declared directly
on the model. This way we allow for future subclassing.
This way you can specify constraints and indexes easily:

    _some_check = models.Constraint("CHECK(a > 1)")

task-3390431

Part-of: #175783
Related: odoo/enterprise#68589
Related: odoo/documentation#11071
Signed-off-by: Raphael Collet <[email protected]>
robodoo pushed a commit to odoo/odoo that referenced this pull request Nov 8, 2024
We should not parse the definition of the constraint. Therefore, let's
handle all constraints in the same way. Note that we do not define
manually FOREIGN KEYS, so we can just remove this code and add a new
class in the future if we need to handle it differently.

Part-of: #175783
Related: odoo/enterprise#68589
Related: odoo/documentation#11071
Signed-off-by: Raphael Collet <[email protected]>
robodoo pushed a commit to odoo/odoo that referenced this pull request Nov 8, 2024
Introducting models.Index and UniqueIndex that can be declared in
models. There is no longer a need for virtual constraints (which are
always implemented using an index).

    _partner_idx = models.Index('(partner_id, res_model)')
    _name_uniq = models.UniqueIndex('(name) WHERE active IS TRUE')

task-3390431

Part-of: #175783
Related: odoo/enterprise#68589
Related: odoo/documentation#11071
Signed-off-by: Raphael Collet <[email protected]>
robodoo pushed a commit to odoo/odoo that referenced this pull request Nov 8, 2024
robodoo pushed a commit to odoo/odoo that referenced this pull request Nov 8, 2024
robodoo pushed a commit to odoo/odoo that referenced this pull request Nov 8, 2024
robodoo pushed a commit to odoo/odoo that referenced this pull request Nov 8, 2024
Since we have a migration code for `_sql_constraints`, remove support
for it and warn when used.

closes #175783

Related: odoo/enterprise#68589
Related: odoo/documentation#11071
Signed-off-by: Raphael Collet <[email protected]>
robodoo pushed a commit that referenced this pull request Nov 8, 2024
task-3390431

closes #11071

Related: odoo/odoo#175783
Related: odoo/enterprise#68589
Signed-off-by: Krzysztof Magusiak (krma) <[email protected]>
@robodoo robodoo closed this Nov 8, 2024
@kmagusiak kmagusiak deleted the master-sql-constraints-object-krma branch November 8, 2024 09:11
@robodoo robodoo added the 18.1 label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants