dto

class advanced_alchemy.extensions.litestar.dto.SQLAlchemyDTO[source]

Bases: AbstractDTO, Generic[T]

Support for domain modelling with SQLAlchemy.

config: ClassVar[SQLAlchemyDTOConfig]

Config objects to define properties of the DTO.

classmethod generate_field_definitions(model_type: type[sqlalchemy.orm.DeclarativeBase]) Generator[DTOFieldDefinition, None, None][source]

Generate DTO field definitions from a SQLAlchemy model.

Parameters:

model_type (Type[sqlalchemy.orm.DeclarativeBase]) – The SQLAlchemy model type to generate field definitions from.

Yields:

collections.abc.Generator[litestar.dto.data_structures.DTOFieldDefinition, None, None] – A generator yielding DTO field definitions.

Raises:
  • RuntimeError – If the mapper cannot be found for the model type.

  • NotImplementedError – If an unsupported property or extension type is encountered.

  • ImproperConfigurationError – If a type cannot be parsed from an element.

classmethod detect_nested_field(field_definition: FieldDefinition) bool[source]

Return True if field_definition represents a nested model field.

Parameters:

field_definition – inspect type to determine if field represents a nested model.

Returns:

True if field_definition represents a nested model field.