Skip to content

Commit 3c68587

Browse files
authored
Merge branch 'tiangolo:main' into byrman_support-mixins
2 parents 168b9ae + 75ce455 commit 3c68587

Some content is hidden

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

51 files changed

+657
-161
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
version: 2
22
updates:
3+
# GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
# Python
39
- package-ecosystem: "pip"
410
directory: "/"
511
schedule:

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-20.04
1919
strategy:
2020
matrix:
21-
python-version: [3.6, 3.7, 3.8, 3.9]
21+
python-version: ["3.6.15", "3.7", "3.8", "3.9", "3.10"]
2222
fail-fast: false
2323

2424
steps:
@@ -54,9 +54,9 @@ jobs:
5454
if: steps.cache.outputs.cache-hit != 'true'
5555
run: python -m poetry install
5656
- name: Lint
57-
if: ${{ matrix.python-version != '3.6' }}
57+
if: ${{ matrix.python-version != '3.6.15' }}
5858
run: python -m poetry run bash scripts/lint.sh
5959
- name: Test
6060
run: python -m poetry run bash scripts/test.sh
6161
- name: Upload coverage
62-
uses: codecov/codecov-action@v1
62+
uses: codecov/codecov-action@v2

docs/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ $ poetry shell
4242

4343
</div>
4444

45-
That will set up the environment variables needed dand will start a new shell with them.
45+
That will set up the environment variables needed and start a new shell with them.
4646

4747
#### Using your local SQLModel
4848

docs/databases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ The language is called **SQL**, the name comes from for **Structured Query Langu
274274

275275
Nevertheless, the language is not only used to *query* for data. It is also used to create records/rows, to update them, to delete them. And to manipulate the database, create tables, etc.
276276

277-
This language is supported by all these databases that handle multiple tables, that's why they are called **SQL Databases**. Although, each database has small variations in the SQL language they support.
277+
This language is supported by all these databases that handle multiple tables, that's why they are called **SQL Databases**. Although, each database has small variations in the SQL language they support (*dialect*).
278278

279279
Let's imagine that the table holding the heroes is called the `hero` table. An example of a SQL query to get all the data from it could look like:
280280

docs/db-to-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ If the user provides this ID:
143143
2
144144
```
145145

146-
...the would be this table (with a single row):
146+
...the result would be this table (with a single row):
147147

148148
<table>
149149
<tr>

docs/help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ And there are several ways to get help too.
1212

1313
## Subscribe to the FastAPI and Friends newsletter
1414

15-
You can subscribe to the (infrequent) [**FastAPI and friends** newsletter](/newsletter/){.internal-link target=_blank} to stay updated about:
15+
You can subscribe to the (infrequent) <a href="https://fastapi.tiangolo.com/newsletter" class="external-link" target="_blank">**FastAPI and friends** newsletter</a> to stay updated about:
1616

1717
* News about FastAPI and friends, including SQLModel 🚀
1818
* Guides 📝

docs/overrides/main.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{% extends "base.html" %}
2+
{%- block scripts %}
3+
{{ super() }}
4+
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
5+
<script>
6+
// This prevents the global search from interfering with qa-bot's internal text input.
7+
document.addEventListener('DOMContentLoaded', () => {
8+
document.querySelectorAll('qa-bot').forEach((x) => {
9+
x.addEventListener('keydown', (event) => {
10+
event.stopPropagation();
11+
});
12+
});
13+
});
14+
</script>
15+
<qa-bot
16+
server="https://tiangolo-sqlmodel.docsqa.jina.ai"
17+
theme="infer"
18+
title="SQLModel Bot"
19+
description="SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness."
20+
style="font-size: 0.8rem"
21+
>
22+
<template>
23+
<dl>
24+
<dt>You can ask questions about SQLModel. Try:</dt>
25+
<dd>Which Python version is supported?</dd>
26+
<dd>How SQLModel interacts with the database?</dd>
27+
<dd>How can I link tables?</dd>
28+
</dl>
29+
</template>
30+
</qa-bot>
31+
{%- endblock %}

docs/release-notes.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,79 @@
22

33
## Latest Changes
44

5+
6+
## 0.0.8
7+
8+
### Fixes
9+
10+
* 🐛 Fix auto detecting and setting `nullable`, allowing overrides in field. PR [#423](https://github.com/tiangolo/sqlmodel/pull/423) by [@JonasKs](https://github.com/JonasKs).
11+
* ♻️ Update `expresion.py`, sync from Jinja2 template, implement `inherit_cache` to solve errors like: `SAWarning: Class SelectOfScalar will not make use of SQL compilation caching`. PR [#422](https://github.com/tiangolo/sqlmodel/pull/422) by [@tiangolo](https://github.com/tiangolo).
12+
13+
### Docs
14+
15+
* 📝 Adjust and clarify docs for `docs/tutorial/create-db-and-table.md`. PR [#426](https://github.com/tiangolo/sqlmodel/pull/426) by [@tiangolo](https://github.com/tiangolo).
16+
* ✏ Fix typo in `docs/tutorial/connect/remove-data-connections.md`. PR [#421](https://github.com/tiangolo/sqlmodel/pull/421) by [@VerdantFox](https://github.com/VerdantFox).
17+
18+
## 0.0.7
19+
20+
### Features
21+
22+
* ✨ Allow setting `unique` in `Field()` for a column. PR [#83](https://github.com/tiangolo/sqlmodel/pull/83) by [@raphaelgibson](https://github.com/raphaelgibson).
23+
* ✨ Update GUID handling to use stdlib `UUID.hex` instead of an `int`. PR [#26](https://github.com/tiangolo/sqlmodel/pull/26) by [@andrewbolster](https://github.com/andrewbolster).
24+
* ✨ Raise an exception when using a Pydantic field type with no matching SQLAlchemy type. PR [#18](https://github.com/tiangolo/sqlmodel/pull/18) by [@elben10](https://github.com/elben10).
25+
* ⬆ Upgrade constrain for SQLAlchemy = ">=1.4.17,<=1.4.41". PR [#371](https://github.com/tiangolo/sqlmodel/pull/371) by [@RobertRosca](https://github.com/RobertRosca).
26+
* ✨ Add new `Session.get()` parameter `execution_options`. PR [#302](https://github.com/tiangolo/sqlmodel/pull/302) by [@tiangolo](https://github.com/tiangolo).
27+
28+
### Fixes
29+
30+
* 🐛 Fix type annotations for `Model.parse_obj()`, and `Model.validate()`. PR [#321](https://github.com/tiangolo/sqlmodel/pull/321) by [@phi-friday](https://github.com/phi-friday).
31+
* 🐛 Fix `Select` and `SelectOfScalar` to inherit cache to avoid warning: `SAWarning: Class SelectOfScalar will not make use of SQL compilation caching`. PR [#234](https://github.com/tiangolo/sqlmodel/pull/234) by [@rabinadk1](https://github.com/rabinadk1).
32+
* 🐛 Fix handling validators for non-default values. PR [#253](https://github.com/tiangolo/sqlmodel/pull/253) by [@byrman](https://github.com/byrman).
33+
* 🐛 Fix fields marked as "set" in models. PR [#117](https://github.com/tiangolo/sqlmodel/pull/117) by [@statt8900](https://github.com/statt8900).
34+
* 🐛 Fix Enum handling in SQLAlchemy. PR [#165](https://github.com/tiangolo/sqlmodel/pull/165) by [@chriswhite199](https://github.com/chriswhite199).
35+
* 🐛 Fix setting nullable property of Fields that don't accept `None`. PR [#79](https://github.com/tiangolo/sqlmodel/pull/79) by [@van51](https://github.com/van51).
36+
* 🐛 Fix SQLAlchemy version 1.4.36 breaks SQLModel relationships (#315). PR [#322](https://github.com/tiangolo/sqlmodel/pull/322) by [@byrman](https://github.com/byrman).
37+
38+
### Docs
39+
40+
* 📝 Update docs for models for updating, `id` should not be updatable. PR [#335](https://github.com/tiangolo/sqlmodel/pull/335) by [@kurtportelli](https://github.com/kurtportelli).
41+
* ✏ Fix broken variable/typo in docs for Read Relationships, `hero_spider_boy.id` => `hero_spider_boy.team_id`. PR [#106](https://github.com/tiangolo/sqlmodel/pull/106) by [@yoannmos](https://github.com/yoannmos).
42+
* 🎨 Remove unwanted highlight in the docs. PR [#233](https://github.com/tiangolo/sqlmodel/pull/233) by [@jalvaradosegura](https://github.com/jalvaradosegura).
43+
* ✏ Fix typos in `docs/databases.md` and `docs/tutorial/index.md`. PR [#35](https://github.com/tiangolo/sqlmodel/pull/35) by [@prrao87](https://github.com/prrao87).
44+
* ✏ Fix typo in `docs/tutorial/relationship-attributes/define-relationships-attributes.md`. PR [#239](https://github.com/tiangolo/sqlmodel/pull/239) by [@jalvaradosegura](https://github.com/jalvaradosegura).
45+
* ✏ Fix typo in `docs/tutorial/fastapi/simple-hero-api.md`. PR [#80](https://github.com/tiangolo/sqlmodel/pull/80) by [@joemudryk](https://github.com/joemudryk).
46+
* ✏ Fix typos in multiple files in the docs. PR [#400](https://github.com/tiangolo/sqlmodel/pull/400) by [@VictorGambarini](https://github.com/VictorGambarini).
47+
* ✏ Fix typo in `docs/tutorial/code-structure.md`. PR [#344](https://github.com/tiangolo/sqlmodel/pull/344) by [@marciomazza](https://github.com/marciomazza).
48+
* ✏ Fix typo in `docs/db-to-code.md`. PR [#155](https://github.com/tiangolo/sqlmodel/pull/155) by [@gr8jam](https://github.com/gr8jam).
49+
* ✏ Fix typo in `docs/contributing.md`. PR [#323](https://github.com/tiangolo/sqlmodel/pull/323) by [@Fardad13](https://github.com/Fardad13).
50+
* ✏ Fix typo in `docs/tutorial/fastapi/tests.md`. PR [#265](https://github.com/tiangolo/sqlmodel/pull/265) by [@johnhoman](https://github.com/johnhoman).
51+
* ✏ Fix typo in `docs/tutorial/where.md`. PR [#286](https://github.com/tiangolo/sqlmodel/pull/286) by [@jalvaradosegura](https://github.com/jalvaradosegura).
52+
* ✏ Fix typos in `docs/tutorial/fastapi/update.md`. PR [#268](https://github.com/tiangolo/sqlmodel/pull/268) by [@cirrusj](https://github.com/cirrusj).
53+
* ✏ Fix typo in `docs/tutorial/fastapi/simple-hero-api.md`. PR [#247](https://github.com/tiangolo/sqlmodel/pull/247) by [@hao-wang](https://github.com/hao-wang).
54+
* ✏ Fix typos in `docs/tutorial/automatic-id-none-refresh.md`, `docs/tutorial/fastapi/update.md`, `docs/tutorial/select.md`. PR [#185](https://github.com/tiangolo/sqlmodel/pull/185) by [@rootux](https://github.com/rootux).
55+
* ✏ Fix typo in `docs/databases.md`. PR [#177](https://github.com/tiangolo/sqlmodel/pull/177) by [@seandlg](https://github.com/seandlg).
56+
* ✏ Fix typos in `docs/tutorial/fastapi/update.md`. PR [#162](https://github.com/tiangolo/sqlmodel/pull/162) by [@wmcgee3](https://github.com/wmcgee3).
57+
* ✏ Fix typos in `docs/tutorial/code-structure.md`, `docs/tutorial/fastapi/multiple-models.md`, `docs/tutorial/fastapi/simple-hero-api.md`, `docs/tutorial/many-to-many/index.md`. PR [#116](https://github.com/tiangolo/sqlmodel/pull/116) by [@moonso](https://github.com/moonso).
58+
* ✏ Fix typo in `docs/tutorial/fastapi/teams.md`. PR [#154](https://github.com/tiangolo/sqlmodel/pull/154) by [@chrisgoddard](https://github.com/chrisgoddard).
59+
* ✏ Fix typo variable in example about relationships and `back_populates`, always use `hero` instead of `owner`. PR [#120](https://github.com/tiangolo/sqlmodel/pull/120) by [@onionj](https://github.com/onionj).
60+
* ✏ Fix typo in `docs/tutorial/fastapi/tests.md`. PR [#113](https://github.com/tiangolo/sqlmodel/pull/113) by [@feanil](https://github.com/feanil).
61+
* ✏ Fix typo in `docs/tutorial/where.md`. PR [#72](https://github.com/tiangolo/sqlmodel/pull/72) by [@ZettZet](https://github.com/ZettZet).
62+
* ✏ Fix typo in `docs/tutorial/code-structure.md`. PR [#91](https://github.com/tiangolo/sqlmodel/pull/91) by [@dhiraj](https://github.com/dhiraj).
63+
* ✏ Fix broken link to newsletter sign-up in `docs/help.md`. PR [#84](https://github.com/tiangolo/sqlmodel/pull/84) by [@mborus](https://github.com/mborus).
64+
* ✏ Fix typos in `docs/tutorial/many-to-many/create-models-with-link.md`. PR [#45](https://github.com/tiangolo/sqlmodel/pull/45) by [@xginn8](https://github.com/xginn8).
65+
* ✏ Fix typo in `docs/tutorial/index.md`. PR [#398](https://github.com/tiangolo/sqlmodel/pull/398) by [@ryangrose](https://github.com/ryangrose).
66+
67+
### Internal
68+
69+
* ♻ Refactor internal statements to simplify code. PR [#53](https://github.com/tiangolo/sqlmodel/pull/53) by [@yezz123](https://github.com/yezz123).
70+
* ♻ Refactor internal imports to reduce redundancy. PR [#272](https://github.com/tiangolo/sqlmodel/pull/272) by [@aminalaee](https://github.com/aminalaee).
71+
* ⬆ Update development requirement for FastAPI from `^0.68.0` to `^0.68.1`. PR [#48](https://github.com/tiangolo/sqlmodel/pull/48) by [@alucarddelta](https://github.com/alucarddelta).
72+
* ⏪ Revert upgrade Poetry, to make a release that supports Python 3.6 first. PR [#417](https://github.com/tiangolo/sqlmodel/pull/417) by [@tiangolo](https://github.com/tiangolo).
73+
* 👷 Add dependabot for GitHub Actions. PR [#410](https://github.com/tiangolo/sqlmodel/pull/410) by [@tiangolo](https://github.com/tiangolo).
74+
* ⬆️ Upgrade Poetry to version `==1.2.0b1`. PR [#303](https://github.com/tiangolo/sqlmodel/pull/303) by [@tiangolo](https://github.com/tiangolo).
75+
* 👷 Add CI for Python 3.10. PR [#305](https://github.com/tiangolo/sqlmodel/pull/305) by [@tiangolo](https://github.com/tiangolo).
76+
* 📝 Add Jina's QA Bot to the docs to help people that want to ask quick questions. PR [#263](https://github.com/tiangolo/sqlmodel/pull/263) by [@tiangolo](https://github.com/tiangolo).
77+
* 👷 Upgrade Codecov GitHub Action. PR [#304](https://github.com/tiangolo/sqlmodel/pull/304) by [@tiangolo](https://github.com/tiangolo).
578
* 💚 Only run CI on push when on master, to avoid duplicate runs on PRs. PR [#244](https://github.com/tiangolo/sqlmodel/pull/244) by [@tiangolo](https://github.com/tiangolo).
679
* 🔧 Upgrade MkDocs Material and update configs. PR [#217](https://github.com/tiangolo/sqlmodel/pull/217) by [@tiangolo](https://github.com/tiangolo).
780
* ⬆ Upgrade mypy, fix type annotations. PR [#218](https://github.com/tiangolo/sqlmodel/pull/218) by [@tiangolo](https://github.com/tiangolo).

docs/tutorial/automatic-id-none-refresh.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Automatic IDs, None Defaults, and Refreshing Data
22

3-
In the previous chapter we saw how to add rows to the database using **SQLModel**.
3+
In the previous chapter, we saw how to add rows to the database using **SQLModel**.
44

55
Now let's talk a bit about why the `id` field **can't be `NULL`** on the database because it's a **primary key**, and we declare it using `Field(primary_key=True)`.
66

@@ -11,7 +11,7 @@ But the same `id` field actually **can be `None`** in the Python code, so we dec
1111

1212
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:6-10]!}
1313

14-
# Code below ommitted 👇
14+
# Code below omitted 👇
1515
```
1616

1717
<details>
@@ -68,7 +68,7 @@ If we ran this code before saving the hero to the database and the `hero_1.id` w
6868
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
6969
```
7070

71-
But by declaring it with `Optional[int]` the editor will help us to avoid writing broken code by showing us a warning telling us that the code could be invalid if `hero_1.id` is `None`. 🔍
71+
But by declaring it with `Optional[int]`, the editor will help us to avoid writing broken code by showing us a warning telling us that the code could be invalid if `hero_1.id` is `None`. 🔍
7272

7373
## Print the Default `id` Values
7474

@@ -79,7 +79,7 @@ We can confirm that by printing our heroes before adding them to the database:
7979

8080
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-31]!}
8181

82-
# Code below ommitted 👇
82+
# Code below omitted 👇
8383
```
8484

8585
<details>
@@ -98,7 +98,7 @@ That will output:
9898
```console
9999
$ python app.py
100100

101-
// Output above ommitted 👆
101+
// Output above omitted 👆
102102

103103
Before interacting with the database
104104
Hero 1: id=None name='Deadpond' secret_name='Dive Wilson' age=None
@@ -118,7 +118,7 @@ What happens when we `add` these objects to the **session**?
118118

119119
After we add the `Hero` instance objects to the **session**, the IDs are *still* `None`.
120120

121-
We can verify by creating a session using a `with` block, and adding the objects. And then printing them again:
121+
We can verify by creating a session using a `with` block and adding the objects. And then printing them again:
122122

123123
```Python hl_lines="19-21"
124124
# Code above omitted 👆
@@ -144,7 +144,7 @@ This will, again, output the `id`s of the objects as `None`:
144144
```console
145145
$ python app.py
146146

147-
// Output above ommitted 👆
147+
// Output above omitted 👆
148148

149149
After adding to the session
150150
Hero 1: id=None name='Deadpond' secret_name='Dive Wilson' age=None
@@ -165,7 +165,7 @@ Then we can `commit` the changes in the session, and print again:
165165

166166
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-48]!}
167167

168-
# Code below ommitted 👇
168+
# Code below omitted 👇
169169
```
170170

171171
<details>
@@ -184,7 +184,7 @@ And now, something unexpected happens, look at the output, it seems as if the `H
184184
```console
185185
$ python app.py
186186

187-
// Output above ommitted 👆
187+
// Output above omitted 👆
188188

189189
// Here the engine talks to the database, the SQL part
190190
INFO Engine BEGIN (implicit)
@@ -450,7 +450,7 @@ Now let's review all this code once again.
450450

451451
And as we created the **engine** with `echo=True`, we can see the SQL statements being executed at each step.
452452

453-
```{ .python .annotate hl_lines="54" }
453+
```{ .python .annotate }
454454
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial002.py!}
455455
```
456456

docs/tutorial/code-structure.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The class `Hero` has a reference to the class `Team` internally.
88

99
But the class `Team` also has a reference to the class `Hero`.
1010

11-
So, if those two classes where in separate files and you tried to import the classes in each other's file directly, it would result in a **circular import**. 🔄
11+
So, if those two classes were in separate files and you tried to import the classes in each other's file directly, it would result in a **circular import**. 🔄
1212

1313
And Python will not be able to handle it and will throw an error. 🚨
1414

@@ -170,7 +170,7 @@ Let's assume that now the file structure is:
170170

171171
The problem with circular imports is that Python can't resolve them at <abbr title="While it is executing the program, as oposed to the code as just text in a file stored on disk.">*runtime*</abbr>.
172172

173-
but when using Python **type annotations** it's very common to need to declare the type of some variables with classes imported from other files.
173+
But when using Python **type annotations** it's very common to need to declare the type of some variables with classes imported from other files.
174174

175175
And the files with those classes might **also need to import** more things from the first files.
176176

@@ -198,7 +198,7 @@ It has a value of `True` for editors and tools that analyze the code with the ty
198198

199199
But when Python is executing, its value is `False`.
200200

201-
So, we can us it in an `if` block and import things inside the `if` block. And they will be "imported" only for editors, but not at runtime.
201+
So, we can use it in an `if` block and import things inside the `if` block. And they will be "imported" only for editors, but not at runtime.
202202

203203
### Hero Model File
204204

0 commit comments

Comments
 (0)