+
Skip to content

add one-to-one field #116

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 30, 2021
Merged

add one-to-one field #116

merged 4 commits into from
Sep 30, 2021

Conversation

aminalaee
Copy link
Member

@aminalaee aminalaee commented Sep 27, 2021

Fixes #110

Adds OneToOne which is similar to a ForeignKey but adds a UniqueConstraint to the ForeignKey.

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


class Person(orm.Model):
    registry = models
    fields = {
        "id": orm.Integer(primary_key=True),
        "email": orm.String(max_length=100),
        "profile": orm.OneToOne(Profile),
    }

Needs documentation and should go after #115 to implement ON DELETE.

@aminalaee aminalaee merged commit b283dd2 into encode:master Sep 30, 2021
@aminalaee aminalaee deleted the one-to-one-field branch September 30, 2021 06:23
@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.

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