From 1e3359aa48d2a4e338057b9fd4eb0b83cec42a6b Mon Sep 17 00:00:00 2001 From: byrman Date: Mon, 28 Feb 2022 11:58:25 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=9B=20Support=20mixins.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqlmodel/main.py | 2 +- tests/test_mixin.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/test_mixin.py diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 4d6d2f2712..0118877afd 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -323,7 +323,7 @@ def __init__( # triggers an error base_is_table = False for base in bases: - config = getattr(base, "__config__") + config = getattr(base, "__config__", None) if config and getattr(config, "table", False): base_is_table = True break diff --git a/tests/test_mixin.py b/tests/test_mixin.py new file mode 100644 index 0000000000..1e81ac37bd --- /dev/null +++ b/tests/test_mixin.py @@ -0,0 +1,17 @@ +from typing import Optional + +import pytest +from sqlmodel import Field, SQLModel + + +class FooMixin: + pass + + +@pytest.mark.usefixtures("clear_sqlmodel") +def test_mixin(): + class Hero(FooMixin, SQLModel, table=True): + id: Optional[int] = Field(default=None, primary_key=True) + name: str + secret_name: str + age: Optional[int] = None From 168b9ae9d9385862a8d72e67346be92b9226a09a Mon Sep 17 00:00:00 2001 From: byrman Date: Mon, 28 Feb 2022 12:49:05 +0100 Subject: [PATCH 2/4] Add a docstring to the test. --- tests/test_mixin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_mixin.py b/tests/test_mixin.py index 1e81ac37bd..48864e83ab 100644 --- a/tests/test_mixin.py +++ b/tests/test_mixin.py @@ -10,6 +10,12 @@ class FooMixin: @pytest.mark.usefixtures("clear_sqlmodel") def test_mixin(): + """Test SQLModel in combination with a mixin. + + https://github.com/tiangolo/sqlmodel/issues/254 + + """ + class Hero(FooMixin, SQLModel, table=True): id: Optional[int] = Field(default=None, primary_key=True) name: str From cf36b2d9baccf527bc61071850f102e2cd8bf6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Fri, 16 Dec 2022 22:45:51 +0400 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=91=B7=20Refactor=20CI=20artifact=20u?= =?UTF-8?q?pload/download=20for=20docs=20previews=20(#514)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docs.yml | 2 +- .github/workflows/preview-docs.yml | 7 ++++++- scripts/zip-docs.sh | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 0d92d1feb3..6400691533 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -68,7 +68,7 @@ jobs: - uses: actions/upload-artifact@v3 with: name: docs-zip - path: ./docs.zip + path: ./site/docs.zip - name: Deploy to Netlify uses: nwtgck/actions-netlify@v1.1.5 with: diff --git a/.github/workflows/preview-docs.yml b/.github/workflows/preview-docs.yml index 10e44328d6..3550a9b441 100644 --- a/.github/workflows/preview-docs.yml +++ b/.github/workflows/preview-docs.yml @@ -11,6 +11,10 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3.1.0 + - name: Clean site + run: | + rm -rf ./site + mkdir ./site - name: Download Artifact Docs uses: dawidd6/action-download-artifact@v2.24.2 with: @@ -18,9 +22,10 @@ jobs: workflow: build-docs.yml run_id: ${{ github.event.workflow_run.id }} name: docs-zip + path: ./site/ - name: Unzip docs run: | - rm -rf ./site + cd ./site unzip docs.zip rm -f docs.zip - name: Deploy to Netlify diff --git a/scripts/zip-docs.sh b/scripts/zip-docs.sh index f2b7ba3be3..69315f5ddd 100644 --- a/scripts/zip-docs.sh +++ b/scripts/zip-docs.sh @@ -3,7 +3,9 @@ set -x set -e +cd ./site + if [ -f docs.zip ]; then rm -rf docs.zip fi -zip -r docs.zip ./site +zip -r docs.zip ./ From 7b3148c0b4bba173710c774c951cee89dcc95c39 Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 16 Dec 2022 18:46:26 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index f7c2f559b8..4a4788f3bd 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ## Latest Changes +* 👷 Refactor CI artifact upload/download for docs previews. PR [#514](https://github.com/tiangolo/sqlmodel/pull/514) by [@tiangolo](https://github.com/tiangolo). * ✏️ Fix typo in internal function name `get_sqlachemy_type()`. PR [#496](https://github.com/tiangolo/sqlmodel/pull/496) by [@cmarqu](https://github.com/cmarqu). * ⬆ Bump actions/cache from 2 to 3. PR [#497](https://github.com/tiangolo/sqlmodel/pull/497) by [@dependabot[bot]](https://github.com/apps/dependabot). * ✏️ Fix typo in docs. PR [#446](https://github.com/tiangolo/sqlmodel/pull/446) by [@davidbrochart](https://github.com/davidbrochart).