Skip to content

OneToOne class

edgy.OneToOneField

Bases: ForeignKeyFieldFactory

Representation of a one to one field.

get_column_type classmethod

get_column_type(**kwargs)

Returns the propery column type for the field

PARAMETER DESCRIPTION
**kwargs

TYPE: Any DEFAULT: {}

Source code in edgy/core/db/fields/one_to_one_keys.py
73
74
75
76
@classmethod
def get_column_type(cls, **kwargs: Any) -> Any:
    """Returns the propery column type for the field"""
    return None

get_constraints classmethod

get_constraints(**kwargs)
PARAMETER DESCRIPTION
**kwargs

TYPE: Any DEFAULT: {}

Source code in edgy/core/db/fields/one_to_one_keys.py
78
79
80
@classmethod
def get_constraints(cls, **kwargs: Any) -> Any:
    return []

validate classmethod

validate(**kwargs)
PARAMETER DESCRIPTION
**kwargs

TYPE: Any DEFAULT: {}

Source code in edgy/core/db/fields/one_to_one_keys.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@classmethod
def validate(cls, **kwargs: Any) -> None:
    on_delete = kwargs.get("on_delete", None)
    on_update = kwargs.get("on_update", None)
    null = kwargs.get("null")

    if on_delete is None:
        raise FieldDefinitionError("on_delete must not be null")

    if on_delete == SET_NULL and not null:
        raise FieldDefinitionError("When SET_NULL is enabled, null must be True.")

    if on_update and (on_update == SET_NULL and not null):
        raise FieldDefinitionError("When SET_NULL is enabled, null must be True.")