Skip to content

Commit

Permalink
Merge branch 'main' into feature/mapped_column
Browse files Browse the repository at this point in the history
  • Loading branch information
svlandeg authored Feb 24, 2025
2 parents 1f0351b + ce22f2a commit 1f5d33c
Show file tree
Hide file tree
Showing 53 changed files with 315 additions and 11,223 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
- mkdocs.no-insiders.yml
- .github/workflows/build-docs.yml
- .github/workflows/deploy-docs.yml
- data/**
build-docs:
needs:
Expand All @@ -58,7 +59,7 @@ jobs:
with:
python-version: "3.11"
- name: Setup uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5
with:
version: "0.4.15"
enable-cache: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
python-version: "3.11"
- name: Setup uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5
with:
version: "0.4.15"
enable-cache: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/latest-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- uses: tiangolo/[email protected].1
- uses: tiangolo/[email protected].2
with:
token: ${{ secrets.GITHUB_TOKEN }}
latest_changes_file: docs/release-notes.md
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.9.0
uses: pypa/gh-action-pypi-publish@v1.12.3
14 changes: 12 additions & 2 deletions .github/workflows/smokeshow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
python-version: '3.9'
- name: Setup uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5
with:
version: "0.4.15"
enable-cache: true
Expand All @@ -35,7 +35,17 @@ jobs:
path: htmlcov
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- run: smokeshow upload htmlcov
# Try 5 times to upload coverage to smokeshow
- name: Upload coverage to Smokeshow
run: |
for i in 1 2 3 4 5; do
if smokeshow upload htmlcov; then
echo "Smokeshow upload success!"
break
fi
echo "Smokeshow upload error, sleep 1 sec and try again."
sleep 1
done
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 95
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ env:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest ]
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
Expand All @@ -36,15 +35,23 @@ jobs:
pydantic-version:
- pydantic-v1
- pydantic-v2
include:
- os: ubuntu-22.04
python-version: "3.7"
pydantic-version: pydantic-v1
- os: ubuntu-22.04
python-version: "3.7"
pydantic-version: pydantic-v2
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5
with:
version: "0.4.15"
enable-cache: true
Expand Down Expand Up @@ -92,7 +99,7 @@ jobs:
with:
python-version: '3.12'
- name: Setup uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5
with:
version: "0.4.15"
enable-cache: true
Expand Down
1 change: 0 additions & 1 deletion data/members.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
members:
- login: tiangolo
- login: estebanx64
- login: alejsdev
128 changes: 3 additions & 125 deletions docs/advanced/decimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,7 @@ For the database, **SQLModel** will use <a href="https://docs.sqlalchemy.org/en/

Let's say that each hero in the database will have an amount of money. We could make that field a `Decimal` type using the `condecimal()` function:

//// tab | Python 3.10+

```python hl_lines="11"
{!./docs_src/advanced/decimal/tutorial001_py310.py[ln:1-11]!}

# More code here later 👇
```

////

//// tab | Python 3.7+

```python hl_lines="12"
{!./docs_src/advanced/decimal/tutorial001.py[ln:1-12]!}

# More code here later 👇
```

////

/// details | 👀 Full file preview

//// tab | Python 3.10+

```Python
{!./docs_src/advanced/decimal/tutorial001_py310.py!}
```

////

//// tab | Python 3.7+

```Python
{!./docs_src/advanced/decimal/tutorial001.py!}
```

////

///
{* ./docs_src/advanced/decimal/tutorial001_py310.py ln[1:11] hl[11] *}

Here we are saying that `money` can have at most `5` digits with `max_digits`, **this includes the integers** (to the left of the decimal dot) **and the decimals** (to the right of the decimal dot).

Expand Down Expand Up @@ -105,97 +67,13 @@ Make sure you adjust the number of digits and decimal places for your own needs,

When creating new models you can actually pass normal (`float`) numbers, Pydantic will automatically convert them to `Decimal` types, and **SQLModel** will store them as `Decimal` types in the database (using SQLAlchemy).

//// tab | Python 3.10+

```Python hl_lines="4-6"
# Code above omitted 👆

{!./docs_src/advanced/decimal/tutorial001_py310.py[ln:24-34]!}

# Code below omitted 👇
```

////

//// tab | Python 3.7+

```Python hl_lines="4-6"
# Code above omitted 👆

{!./docs_src/advanced/decimal/tutorial001.py[ln:25-35]!}

# Code below omitted 👇
```

////

/// details | 👀 Full file preview

//// tab | Python 3.10+

```Python
{!./docs_src/advanced/decimal/tutorial001_py310.py!}
```

////

//// tab | Python 3.7+

```Python
{!./docs_src/advanced/decimal/tutorial001.py!}
```

////

///
{* ./docs_src/advanced/decimal/tutorial001_py310.py ln[24:34] hl[25:27] *}

## Select Decimal data

Then, when working with Decimal types, you can confirm that they indeed avoid those rounding errors from floats:

//// tab | Python 3.10+

```Python hl_lines="15-16"
# Code above omitted 👆

{!./docs_src/advanced/decimal/tutorial001_py310.py[ln:37-50]!}

# Code below omitted 👇
```

////

//// tab | Python 3.7+

```Python hl_lines="15-16"
# Code above omitted 👆

{!./docs_src/advanced/decimal/tutorial001.py[ln:38-51]!}

# Code below omitted 👇
```

////

/// details | 👀 Full file preview

//// tab | Python 3.10+

```Python
{!./docs_src/advanced/decimal/tutorial001_py310.py!}
```

////

//// tab | Python 3.7+

```Python
{!./docs_src/advanced/decimal/tutorial001.py!}
```

////

///
{* ./docs_src/advanced/decimal/tutorial001_py310.py ln[37:50] hl[49:50] *}

## Review the results

Expand Down
Loading

0 comments on commit 1f5d33c

Please sign in to comment.