515 lines
12 KiB
Markdown
515 lines
12 KiB
Markdown
<a name="fields.model_fields"></a>
|
|
# fields.model\_fields
|
|
|
|
<a name="fields.model_fields.is_field_nullable"></a>
|
|
#### is\_field\_nullable
|
|
|
|
```python
|
|
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 nullable
|
|
- `default (Any)`: value or function to be called as default in python
|
|
- `server_default (Any)`: function to be called as default by sql server
|
|
- `pydantic_only (Optional[bool])`: flag if fields should not be included in the sql table
|
|
|
|
**Returns**:
|
|
|
|
`(bool)`: result of the check
|
|
|
|
<a name="fields.model_fields.is_auto_primary_key"></a>
|
|
#### is\_auto\_primary\_key
|
|
|
|
```python
|
|
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 field
|
|
- `autoincrement (bool)`: flag if field should be autoincrement
|
|
|
|
**Returns**:
|
|
|
|
`(bool)`: result of the check
|
|
|
|
<a name="fields.model_fields.ModelFieldFactory"></a>
|
|
## ModelFieldFactory Objects
|
|
|
|
```python
|
|
class ModelFieldFactory()
|
|
```
|
|
|
|
Default field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.ModelFieldFactory._bases"></a>
|
|
#### \_bases
|
|
|
|
<a name="fields.model_fields.ModelFieldFactory._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.ModelFieldFactory.__new__"></a>
|
|
#### \_\_new\_\_
|
|
|
|
```python
|
|
| __new__(cls, *args: Any, **kwargs: Any) -> Type[BaseField]
|
|
```
|
|
|
|
<a name="fields.model_fields.ModelFieldFactory.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.ModelFieldFactory.validate"></a>
|
|
#### validate
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.String"></a>
|
|
## String Objects
|
|
|
|
```python
|
|
class String(ModelFieldFactory, str)
|
|
```
|
|
|
|
String field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.String._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.String.__new__"></a>
|
|
#### \_\_new\_\_
|
|
|
|
```python
|
|
| __new__(cls, *, allow_blank: bool = True, strip_whitespace: bool = False, min_length: int = None, max_length: int = None, curtail_length: int = None, regex: str = None, **kwargs: Any) -> Type[BaseField]
|
|
```
|
|
|
|
<a name="fields.model_fields.String.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.String.validate"></a>
|
|
#### validate
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.Integer"></a>
|
|
## Integer Objects
|
|
|
|
```python
|
|
class Integer(ModelFieldFactory, int)
|
|
```
|
|
|
|
Integer field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.Integer._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.Integer.__new__"></a>
|
|
#### \_\_new\_\_
|
|
|
|
```python
|
|
| __new__(cls, *, minimum: int = None, maximum: int = None, multiple_of: int = None, **kwargs: Any) -> Type[BaseField]
|
|
```
|
|
|
|
<a name="fields.model_fields.Integer.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.Text"></a>
|
|
## Text Objects
|
|
|
|
```python
|
|
class Text(ModelFieldFactory, str)
|
|
```
|
|
|
|
Text field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.Text._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.Text.__new__"></a>
|
|
#### \_\_new\_\_
|
|
|
|
```python
|
|
| __new__(cls, *, allow_blank: bool = True, strip_whitespace: bool = False, **kwargs: Any) -> Type[BaseField]
|
|
```
|
|
|
|
<a name="fields.model_fields.Text.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.Float"></a>
|
|
## Float Objects
|
|
|
|
```python
|
|
class Float(ModelFieldFactory, float)
|
|
```
|
|
|
|
Float field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.Float._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.Float.__new__"></a>
|
|
#### \_\_new\_\_
|
|
|
|
```python
|
|
| __new__(cls, *, minimum: float = None, maximum: float = None, multiple_of: int = None, **kwargs: Any) -> Type[BaseField]
|
|
```
|
|
|
|
<a name="fields.model_fields.Float.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.DateTime"></a>
|
|
## DateTime Objects
|
|
|
|
```python
|
|
class DateTime(ModelFieldFactory, datetime.datetime)
|
|
```
|
|
|
|
DateTime field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.DateTime._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.DateTime.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.Date"></a>
|
|
## Date Objects
|
|
|
|
```python
|
|
class Date(ModelFieldFactory, datetime.date)
|
|
```
|
|
|
|
Date field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.Date._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.Date.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.Time"></a>
|
|
## Time Objects
|
|
|
|
```python
|
|
class Time(ModelFieldFactory, datetime.time)
|
|
```
|
|
|
|
Time field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.Time._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.Time.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.JSON"></a>
|
|
## JSON Objects
|
|
|
|
```python
|
|
class JSON(ModelFieldFactory, pydantic.Json)
|
|
```
|
|
|
|
JSON field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.JSON._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.JSON.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.BigInteger"></a>
|
|
## BigInteger Objects
|
|
|
|
```python
|
|
class BigInteger(Integer, int)
|
|
```
|
|
|
|
BigInteger field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.BigInteger._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.BigInteger.__new__"></a>
|
|
#### \_\_new\_\_
|
|
|
|
```python
|
|
| __new__(cls, *, minimum: int = None, maximum: int = None, multiple_of: int = None, **kwargs: Any) -> Type[BaseField]
|
|
```
|
|
|
|
<a name="fields.model_fields.BigInteger.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.Decimal"></a>
|
|
## Decimal Objects
|
|
|
|
```python
|
|
class Decimal(ModelFieldFactory, decimal.Decimal)
|
|
```
|
|
|
|
Decimal field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.Decimal._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.Decimal.__new__"></a>
|
|
#### \_\_new\_\_
|
|
|
|
```python
|
|
| __new__(cls, *, minimum: float = None, maximum: float = None, multiple_of: int = None, precision: int = None, scale: int = None, max_digits: int = None, decimal_places: int = None, **kwargs: Any) -> Type[BaseField]
|
|
```
|
|
|
|
<a name="fields.model_fields.Decimal.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.Decimal.validate"></a>
|
|
#### validate
|
|
|
|
```python
|
|
| @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
|
|
|
|
<a name="fields.model_fields.UUID"></a>
|
|
## UUID Objects
|
|
|
|
```python
|
|
class UUID(ModelFieldFactory, uuid.UUID)
|
|
```
|
|
|
|
UUID field factory that construct Field classes and populated their values.
|
|
|
|
<a name="fields.model_fields.UUID._type"></a>
|
|
#### \_type
|
|
|
|
<a name="fields.model_fields.UUID.__new__"></a>
|
|
#### \_\_new\_\_
|
|
|
|
```python
|
|
| __new__(cls, *, uuid_format: str = "hex", **kwargs: Any) -> Type[BaseField]
|
|
```
|
|
|
|
<a name="fields.model_fields.UUID.get_column_type"></a>
|
|
#### get\_column\_type
|
|
|
|
```python
|
|
| @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
|
|
|