9.4 KiB
fields.model_fields
is_field_nullable
is_field_nullable(nullable: Optional[bool], default: Any, server_default: Any, pydantic_only: Optional[bool]) -> bool
Checks if the given field should be nullable/ optional based on parameters given.
Arguments:
nullable(Optional[bool]): flag explicit setting a column as nullabledefault(Any): value or function to be called as default in pythonserver_default(Any): function to be called as default by sql serverpydantic_only(Optional[bool]): flag if fields should not be included in the sql table
Returns:
bool: result of the check
is_auto_primary_key
is_auto_primary_key(primary_key: bool, autoincrement: bool) -> bool
Checks if field is an autoincrement pk -> if yes it's optional.
Arguments:
primary_key(bool): flag if field is a pk fieldautoincrement(bool): flag if field should be autoincrement
Returns:
bool: result of the check
ModelFieldFactory Objects
class ModelFieldFactory()
Default field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
validate
| @classmethod
| validate(cls, **kwargs: Any) -> None
Used to validate if all required parameters on a given field type are set.
Arguments:
kwargs(Any): all params passed during construction
String Objects
class String(ModelFieldFactory, str)
String field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
validate
| @classmethod
| validate(cls, **kwargs: Any) -> None
Used to validate if all required parameters on a given field type are set.
Arguments:
kwargs(Any): all params passed during construction
Integer Objects
class Integer(ModelFieldFactory, int)
Integer field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
Text Objects
class Text(ModelFieldFactory, str)
Text field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
Float Objects
class Float(ModelFieldFactory, float)
Float field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
DateTime Objects
class DateTime(ModelFieldFactory, datetime.datetime)
DateTime field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
Date Objects
class Date(ModelFieldFactory, datetime.date)
Date field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
Time Objects
class Time(ModelFieldFactory, datetime.time)
Time field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
JSON Objects
class JSON(ModelFieldFactory, pydantic.Json)
JSON field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
BigInteger Objects
class BigInteger(Integer, int)
BigInteger field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
Decimal Objects
class Decimal(ModelFieldFactory, decimal.Decimal)
Decimal field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options
validate
| @classmethod
| validate(cls, **kwargs: Any) -> None
Used to validate if all required parameters on a given field type are set.
Arguments:
kwargs(Any): all params passed during construction
UUID Objects
class UUID(ModelFieldFactory, uuid.UUID)
UUID field factory that construct Field classes and populated their values.
get_column_type
| @classmethod
| get_column_type(cls, **kwargs: Any) -> Any
Return proper type of db column for given field type. Accepts required and optional parameters that each column type accepts.
Arguments:
kwargs(Any): key, value pairs of sqlalchemy options
Returns:
sqlalchemy Column: initialized column with proper options