Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/sa_model_type_mapping' i…
Browse files Browse the repository at this point in the history
…nto feature/sa_model_type_mapping
  • Loading branch information
sambadi committed Feb 14, 2024
2 parents 728d5b7 + 6b5f287 commit fb58b86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/advanced/change-default-type-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def map_python_type_to_sa_type(type_: "PythonType", meta: "PydanticMeta", annota

## Current mapping

| Python type | SqlAlchemy type |
| Python type | SqlAlchemy type |
|-----------------------|------------------------------------------------------------------------------------------------------------------------------------|
| Enum | `lambda type_, meta, annotation: sa_Enum(type_)` |
| str | `lambda type_, meta, annotation: AutoString(length=getattr(meta, "max_length", None))` |
| str | `lambda type_, meta, annotation: AutoString(length=getattr(meta, "max_length", None))` |
| float | Float |
| bool | Boolean |
| int | Integer |
Expand All @@ -67,4 +67,4 @@ def map_python_type_to_sa_type(type_: "PythonType", meta: "PydanticMeta", annota
| ipaddress.IPv6Network | AutoString |
| Path | AutoString |
| uuid.UUID | Uuid |
| BaseModel | `lambda type_, meta, annotation: PydanticJSONType(type=annotation)` |
| BaseModel | `lambda type_, meta, annotation: PydanticJSONType(type=annotation)` |
4 changes: 2 additions & 2 deletions docs/advanced/pydantic-json-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Then map Stats to Hero as shown bellow:
{!./docs_src/advanced/pydantic_json_type/tutorial002.py[ln:36-39]!}
```

After all of these actions we can change mutated model, and it will be saved to database after we call `session.commit()`
After all of these actions we can change mutated model, and it will be saved to database after we call `session.commit()`

```{.python .annotate hl_lines="4" }
{!./docs_src/advanced/pydantic_json_type/tutorial002.py[ln:76-94]!}
Expand All @@ -57,4 +57,4 @@ After all of these actions we can change mutated model, and it will be saved to
{!./docs_src/advanced/pydantic_json_type/tutorial002.py!}
```

///
///

0 comments on commit fb58b86

Please sign in to comment.