Source code for loom.core.model.enums

from __future__ import annotations

from enum import StrEnum


[docs] class OnDelete(StrEnum): CASCADE = "CASCADE" SET_NULL = "SET NULL" RESTRICT = "RESTRICT" NO_ACTION = "NO ACTION"
[docs] class OnUpdate(StrEnum): CASCADE = "CASCADE" SET_NULL = "SET NULL" RESTRICT = "RESTRICT" NO_ACTION = "NO ACTION"
[docs] class Cardinality(StrEnum): ONE_TO_ONE = "one_to_one" ONE_TO_MANY = "one_to_many" MANY_TO_ONE = "many_to_one" MANY_TO_MANY = "many_to_many"
[docs] class ServerDefault(StrEnum): NOW = "now" UUID4 = "uuid4"
[docs] class ServerOnUpdate(StrEnum): NOW = "now"
[docs] @classmethod def is_now(cls, value: ServerOnUpdate | str | None) -> bool: """Return whether ``value`` requests the server clock, as enum or string. Args: value: A ``server_onupdate`` declaration; the string form is matched case-insensitively. Returns: ``True`` for ``ServerOnUpdate.NOW`` or ``"now"`` in any case. """ return isinstance(value, str) and value.strip().lower() == cls.NOW.value