MCPcopy
hub / github.com/tortoise/tortoise-orm / required

Method required

tortoise/fields/base.py:349–360  ·  view source on GitHub ↗

Returns ``True`` if the field is required to be provided. It needs to be non-nullable and not have a default or be DB-generated to be required.

(self)

Source from the content-addressed store, hash-verified

347
348 @property
349 def required(self) -> bool:
350 """
351 Returns ``True`` if the field is required to be provided.
352
353 It needs to be non-nullable and not have a default or be DB-generated to be required.
354 """
355 return (
356 self.default is None
357 and not self.null
358 and not self.generated
359 and not self.has_db_default()
360 )
361
362 def get_db_default_value(self) -> DatabaseDefault | None:
363 """Return a DatabaseDefault instance if this field has a db_default, else None."""

Callers

nothing calls this directly

Calls 1

has_db_defaultMethod · 0.95

Tested by

no test coverage detected