Overview & Core — Aquilia Documentation
Comprehensive guide and documentation for Overview & Core in the Aquilia framework. View API reference, examples, and implementation patterns.
Docs / Models / Fields Overview Fields: Overview & Core All fields in Aquilia ORM inherit from the base Field[T] class, implementing the Python descriptor protocol. Descriptors ensure type safety, validation, and serialization. Core Field Parameters Common options accepted by all field types: Parameter Type Default Description ))} Descriptor Contract Accessing fields is fully synchronous. Cleaned values are automatically coerced: class User(Model): name = CharField(max_length=150) # Class-level access yields the Field instance reveal_type(User.name) # -> CharField # Instance-level access yields the underlying coerced Python type user = User(name="Alice") reveal_type(user.name) # -> str Creating Custom Fields To define a custom field, inherit from Field[T] and implement sql_type(): from aquilia.models import Field from aquilia.models.fields_module import FieldValidationError class HexColorField(Field[str]): _field_type = "COLOR" _python_type = str def sql_type(self, dialect: str = "sqlite") -> str: return "VARCHAR(7)" def validate(self, value: Any) -> str: value = super().validate(value) if value is not None: if not isinstance(value, str) or not value.startswith("#") or len(value) != 7: raise FieldValidationError(self.name, "Must be a valid hex color string (e.g. #FF00FF)") return value Overview Numeric Fields )
Go to Homepage