+
Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Conversation

aminalaee
Copy link
Contributor

@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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

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