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 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 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.

Add support for One-To-One relations

1 participant