+
Skip to content

support for ON DELETE actions #115

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

Merged
merged 4 commits into from
Sep 29, 2021
Merged

Conversation

aminalaee
Copy link
Member

@aminalaee aminalaee commented Sep 26, 2021

Adds support for ON DELETE <ACTION> database-level constraints:

class Album(orm.Model):
    registry = models
    fields = {
        "id": orm.Integer(primary_key=True),
        "name": orm.String(max_length=100),
    }


class Track(orm.Model):
    registry = models
    fields = {
        "id": orm.Integer(primary_key=True),
        "album": orm.ForeignKey("Album", on_delete=orm.CASCADE),
        "title": orm.String(max_length=100),
        "position": orm.Integer(),
    }

Supported actions by SQLAlchemy:
CASCADE, RESTRICT, SET NULL, NO ACTION, SET DEFAULT

Supported actions by ORM (so far):
CASCADE, RESTRICT, SET NULL

I left out NO ACTION intentionally since it is the default behaviour.

@aminalaee aminalaee mentioned this pull request Sep 28, 2021
@aminalaee aminalaee merged commit 43f3075 into encode:master Sep 29, 2021
@aminalaee aminalaee deleted the on-delete-actions branch September 29, 2021 05:41
@aminalaee aminalaee mentioned this pull request Oct 30, 2021
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.

1 participant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载