Skip to content

Commit 0ca7bdf

Browse files
authored
Merge branch 'main' into ami/pydantic-jsonb
2 parents 376b41e + 21a3978 commit 0ca7bdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+128
-155
lines changed

.github/DISCUSSION_TEMPLATE/questions.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ body:
6464
If I (or someone) can copy it, run it, and see it right away, there's a much higher chance I (or someone) will be able to help you.
6565
6666
placeholder: |
67-
from typing import Optional
68-
6967
from sqlmodel import Field, Session, SQLModel, create_engine
7068
7169
7270
class Hero(SQLModel, table=True):
73-
id: Optional[int] = Field(default=None, primary_key=True)
71+
id: int | None = Field(default=None, primary_key=True)
7472
name: str
7573
secret_name: str
76-
age: Optional[int] = None
74+
age: int | None = None
7775
7876
7977
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")

.github/workflows/build-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
with:
6060
python-version: "3.11"
6161
- name: Setup uv
62-
uses: astral-sh/setup-uv@v5
62+
uses: astral-sh/setup-uv@v6
6363
with:
6464
version: "0.4.15"
6565
enable-cache: true

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
with:
3030
python-version: "3.11"
3131
- name: Setup uv
32-
uses: astral-sh/setup-uv@v5
32+
uses: astral-sh/setup-uv@v6
3333
with:
3434
version: "0.4.15"
3535
enable-cache: true

.github/workflows/smokeshow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
python-version: '3.9'
2323
- name: Setup uv
24-
uses: astral-sh/setup-uv@v5
24+
uses: astral-sh/setup-uv@v6
2525
with:
2626
version: "0.4.15"
2727
enable-cache: true

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
with:
4646
python-version: ${{ matrix.python-version }}
4747
- name: Setup uv
48-
uses: astral-sh/setup-uv@v5
48+
uses: astral-sh/setup-uv@v6
4949
with:
5050
version: "0.4.15"
5151
enable-cache: true
@@ -67,7 +67,7 @@ jobs:
6767
if: matrix.pydantic-version == 'pydantic-v2'
6868
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
6969
- name: Lint
70-
if: matrix.pydantic-version == 'pydantic-v2'
70+
if: matrix.pydantic-version == 'pydantic-v2' && matrix.python-version != '3.8'
7171
run: bash scripts/lint.sh
7272
- run: mkdir coverage
7373
- name: Test
@@ -92,7 +92,7 @@ jobs:
9292
with:
9393
python-version: '3.13'
9494
- name: Setup uv
95-
uses: astral-sh/setup-uv@v5
95+
uses: astral-sh/setup-uv@v6
9696
with:
9797
version: "0.4.15"
9898
enable-cache: true

README.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,14 @@ And you want it to have this data:
105105
Then you could create a **SQLModel** model like this:
106106

107107
```Python
108-
from typing import Optional
109-
110108
from sqlmodel import Field, SQLModel
111109

112110

113111
class Hero(SQLModel, table=True):
114-
id: Optional[int] = Field(default=None, primary_key=True)
112+
id: int | None = Field(default=None, primary_key=True)
115113
name: str
116114
secret_name: str
117-
age: Optional[int] = None
115+
age: int | None = None
118116
```
119117

120118
That class `Hero` is a **SQLModel** model, the equivalent of a SQL table in Python code.
@@ -149,17 +147,15 @@ And **inline errors**:
149147

150148
You can learn a lot more about **SQLModel** by quickly following the **tutorial**, but if you need a taste right now of how to put all that together and save to the database, you can do this:
151149

152-
```Python hl_lines="18 21 23-27"
153-
from typing import Optional
154-
150+
```Python hl_lines="16 19 21-25"
155151
from sqlmodel import Field, Session, SQLModel, create_engine
156152

157153

158154
class Hero(SQLModel, table=True):
159-
id: Optional[int] = Field(default=None, primary_key=True)
155+
id: int | None = Field(default=None, primary_key=True)
160156
name: str
161157
secret_name: str
162-
age: Optional[int] = None
158+
age: int | None = None
163159

164160

165161
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
@@ -185,17 +181,15 @@ That will save a **SQLite** database with the 3 heroes.
185181

186182
Then you could write queries to select from that same database, for example with:
187183

188-
```Python hl_lines="15-18"
189-
from typing import Optional
190-
184+
```Python hl_lines="13-17"
191185
from sqlmodel import Field, Session, SQLModel, create_engine, select
192186

193187

194188
class Hero(SQLModel, table=True):
195-
id: Optional[int] = Field(default=None, primary_key=True)
189+
id: int | None = Field(default=None, primary_key=True)
196190
name: str
197191
secret_name: str
198-
age: Optional[int] = None
192+
age: int | None = None
199193

200194

201195
engine = create_engine("sqlite:///database.db")

docs/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ There is a script that you can run locally to test all the code and generate cov
6363
<div class="termy">
6464

6565
```console
66-
$ bash scripts/test-cov-html.sh
66+
$ bash scripts/test.sh
6767
```
6868

6969
</div>

docs/db-to-code.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ For example this class is part of that **Object** Oriented Programming:
252252

253253
```Python
254254
class Hero(SQLModel):
255-
id: Optional[int] = Field(default=None, primary_key=True)
255+
id: int | None = Field(default=None, primary_key=True)
256256
name: str
257257
secret_name: str
258-
age: Optional[int] = None
258+
age: int | None = None
259259
```
260260

261261
* **Relational**: refers to the **SQL Databases**. Remember that they are also called **Relational Databases**, because each of those tables is also called a "**relation**"? That's where the "**Relational**" comes from.

docs/img/index/autocompletion01.png

48.1 KB
Loading

docs/img/index/autocompletion02.png

104 KB
Loading

0 commit comments

Comments
 (0)