Release Notes¶
Latest Changes¶
Docs¶
Internal¶
- 👷 Update
issue-manager.yml
. PR #1103 by @tiangolo. - 👷 Fix coverage processing in CI, one name per matrix run. PR #1104 by @tiangolo.
- 💚 Set
include-hidden-files
toTrue
when using theupload-artifact
GH action. PR #1098 by @svlandeg. - ⬆ [pre-commit.ci] pre-commit autoupdate. PR #1088 by @pre-commit-ci[bot].
0.0.22¶
Fixes¶
- 🐛 Fix support for types with
Optional[Annoated[x, f()]]
, e.g.id: Optional[pydantic.UUID4]
. PR #1093 by @tiangolo.
Docs¶
- ✏️ Fix a typo in
docs/virtual-environments.md
. PR #1085 by @tiangolo. - 📝 Add docs for virtual environments and environment variables, update contributing. PR #1082 by @tiangolo.
- 📝 Add docs about repo management and team. PR #1059 by @tiangolo.
- ✏️ Fix typo in
cascade_delete
docs. PR #1030 by @tiangolo.
Internal¶
- ✅ Refactor test_enums to make them independent of previous imports. PR #1095 by @tiangolo.
- 👷 Update
latest-changes
GitHub Action. PR #1087 by @tiangolo. - ⬆ [pre-commit.ci] pre-commit autoupdate. PR #1028 by @pre-commit-ci[bot].
- ⬆ Bump ruff from 0.4.7 to 0.6.2. PR #1081 by @dependabot[bot].
- 🔧 Update lint script. PR #1084 by @tiangolo.
- 👷 Update Python version for coverage. PR #1083 by @tiangolo.
- 🔧 Update coverage config files. PR #1077 by @tiangolo.
- 🔧 Add URLs to
pyproject.toml
, show up in PyPI. PR #1074 by @tiangolo. - 👷 Do not sync labels as it overrides manually added labels. PR #1073 by @tiangolo.
- 👷 Update configs for GitHub Action labeler, to add only one label. PR #1072 by @tiangolo.
- 👷 Update labeler GitHub Actions permissions and dependencies. PR #1071 by @tiangolo.
- 👷 Add GitHub Action label-checker. PR #1069 by @tiangolo.
- 👷 Add GitHub Action labeler. PR #1068 by @tiangolo.
- 👷 Update GitHub Action add-to-project. PR #1067 by @tiangolo.
- 👷 Add GitHub Action add-to-project. PR #1066 by @tiangolo.
- 📝 Update admonitions in annotations. PR #1065 by @tiangolo.
- 📝 Update links from github.com/tiangolo/sqlmodel to github.com/fastapi/sqlmodel. PR #1064 by @tiangolo.
- 🔧 Update members. PR #1063 by @tiangolo.
- 💄 Add dark-mode logo. PR #1061 by @tiangolo.
- 🔨 Update docs.py script to enable dirty reload conditionally. PR #1060 by @tiangolo.
- 🔧 Update MkDocs previews. PR #1058 by @tiangolo.
- 💄 Update Termynal line-height. PR #1057 by @tiangolo.
- 👷 Upgrade build docs configs. PR #1047 by @tiangolo.
- 👷 Add alls-green for test-redistribute. PR #1055 by @tiangolo.
- 👷 Update docs-previews to handle no docs changes. PR #1056 by @tiangolo.
- 👷🏻 Show docs deployment status and preview URLs in comment. PR #1054 by @tiangolo.
- 🔧 Enable auto dark mode. PR #1046 by @tiangolo.
- 👷 Update issue-manager. PR #1045 by @tiangolo.
- 👷 Update issue-manager.yml GitHub Action permissions. PR #1040 by @tiangolo.
- ♻️ Refactor Deploy Docs GitHub Action to be a script and update token preparing for org. PR #1039 by @tiangolo.
0.0.21¶
Features¶
- ✨ Add support for cascade delete relationships:
cascade_delete
,ondelete
, andpassive_deletes
. Initial PR #983 by @estebanx64. - New docs at: Cascade Delete Relationships.
Docs¶
Internal¶
- ⬆ Bump actions/cache from 3 to 4. PR #783 by @dependabot[bot].
- ⬆ Bump cairosvg from 2.7.0 to 2.7.1. PR #919 by @dependabot[bot].
- ⬆ Bump jinja2 from 3.1.3 to 3.1.4. PR #974 by @dependabot[bot].
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.11 to 1.9.0. PR #987 by @dependabot[bot].
- ⬆ Bump mkdocstrings[python] from 0.23.0 to 0.25.1. PR #927 by @dependabot[bot].
- ⬆ Bump dorny/paths-filter from 2 to 3. PR #972 by @dependabot[bot].
0.0.20¶
Features¶
- ✨ Add official UUID support, docs and tests, internally using new SQLAlchemy 2.0 types. Initial PR #992 by @estebanx64.
- New docs in the Advanced User Guide: UUID (Universally Unique Identifiers).
Docs¶
- ✏️ Fix internal link in
docs/tutorial/create-db-and-table.md
. PR #911 by @tfpgh. - ✏️ Add missing step in
create-db-and-table-with-db-browser.md
. PR #976 by @alejsdev. - ✏️ Fix typo in
docs/tutorial
. PR #943 by @luco17. - ✏️ Fix typo in
sqlmodel/_compat.py
. PR #950 by @Highfire1. - ✏️ Update pip installation command in tutorial. PR #975 by @alejsdev.
- ✏️ Fix typo in
docs/tutorial/relationship-attributes/index.md
. PR #880 by @UncleGoogle.
Internal¶
- ⬆ [pre-commit.ci] pre-commit autoupdate. PR #979 by @pre-commit-ci[bot].
- 🔨 Update docs Termynal scripts to not include line nums for local dev. PR #1018 by @tiangolo.
0.0.19¶
Fixes¶
- 🐛 Fix pydantic
EmailStr
support andmax_length
in several String subclasses. PR #966 by @estebanx64. - 🐛 Fix set varchar limit when
max_length
is set on Pydantic models using Pydantic v2. PR #963 by @estebanx64.
Refactors¶
- ♻️ Refactor generate select template to isolate templated code to the minimum. PR #967 by @tiangolo.
Upgrades¶
- ⬆️ Update minimum SQLAlchemy version to 2.0.14 as that one includes
TryCast
used internally. PR #964 by @tiangolo.
Docs¶
- ✏️ Fix broken link to
@dataclass_transform
(now PEP 681) indocs/features.md
. PR #753 by @soof-golan.
Internal¶
- ⬆️ Upgrade Ruff and Black. PR #968 by @tiangolo.
- ⬆ Bump tiangolo/issue-manager from 0.4.1 to 0.5.0. PR #922 by @dependabot[bot].
- 📌 Pin typing-extensions in tests for compatiblity with Python 3.8, dirty-equals, Pydantic. PR #965 by @tiangolo.
- 👷 Update GitHub Actions to download and upload artifacts. PR #936 by @tiangolo.
- 👷 Tweak CI for test-redistribute, add needed env vars for slim. PR #929 by @tiangolo.
0.0.18¶
Internal¶
In the future SQLModel will include the standard default recommended packages, and sqlmodel-slim
will come without those recommended standard packages and with a group of optional dependencies sqlmodel-slim[standard]
, equivalent to sqlmodel
, for those that want to opt out of those packages.
0.0.17¶
Refactors¶
Docs¶
- 📝 Update ModelRead to ModelPublic documentation and examples. PR #885 by @estebanx64.
- ✨ Add source examples for Python 3.10 and 3.9 with updated syntax. PR #842 by @tiangolo and @estebanx64.
Internal¶
- ⬆ Bump actions/setup-python from 4 to 5. PR #733 by @dependabot[bot].
- 🔨 Update internal scripts and remove unused ones. PR #914 by @tiangolo.
- 🔧 Migrate from Poetry to PDM for the internal build config. PR #912 by @tiangolo.
- 🔧 Update MkDocs, disable cards while I can upgrade to the latest MkDocs Material, that fixes an issue with social cards. PR #888 by @tiangolo.
- 👷 Add cron to run test once a week on monday. PR #869 by @estebanx64.
- ⬆️ Upgrade Ruff version and configs. PR #859 by @tiangolo.
- 🔥 Remove Jina QA Bot as it has been discontinued. PR #840 by @tiangolo.
0.0.16¶
Features¶
- ✨ Add new method
.sqlmodel_update()
to update models in place, including anupdate
parameter for extra data. And fix implementation for the (now documented)update
parameter for.model_validate()
. PR #804 by @tiangolo.- Updated docs: Update Data with FastAPI.
- New docs: Update with Extra Data (Hashed Passwords) with FastAPI.
0.0.15¶
Fixes¶
- 🐛 Fix class initialization compatibility with Pydantic and SQLModel, fixing errors revealed by the latest Pydantic. PR #807 by @tiangolo.
Internal¶
- ⬆ Bump tiangolo/issue-manager from 0.4.0 to 0.4.1. PR #775 by @dependabot[bot].
- 👷 Fix GitHub Actions build docs filter paths for GitHub workflows. PR #738 by @tiangolo.
0.0.14¶
Features¶
- ✨ Add support for Pydantic v2 (while keeping support for v1 if v2 is not available). PR #722 by @tiangolo including initial work in PR #699 by @AntonDeMeester.
0.0.13¶
Fixes¶
- ♻️ Refactor type generation of selects re-order to prioritize models to optimize editor support. PR #718 by @tiangolo.
Refactors¶
- 🔇 Do not raise deprecation warnings for execute as it's automatically used internally. PR #716 by @tiangolo.
- ✅ Move OpenAPI tests inline to simplify updating them with Pydantic v2. PR #709 by @tiangolo.
Upgrades¶
Docs¶
- ✏️ Fix typo, simplify single quote/apostrophe character in "Sister Margaret's" everywhere in the docs. PR #721 by @tiangolo.
- 📝 Update docs for Decimal, use proper types. PR #719 by @tiangolo.
- 📝 Add source examples for Python 3.9 and 3.10. PR #715 by @tiangolo.
Internal¶
- 🙈 Update gitignore, include all coverage files. PR #711 by @tiangolo.
- 🔧 Update config with new pymdown extensions. PR #712 by @tiangolo.
- 🔧 Update docs build setup, add support for sponsors, add sponsor GOVCERT.LU. PR #720 by @tiangolo.
- ⬆ [pre-commit.ci] pre-commit autoupdate. PR #697 by @pre-commit-ci[bot].
- 🔧 Show line numbers in docs during local development. PR #714 by @tiangolo.
- 📝 Update details syntax with new pymdown extensions format. PR #713 by @tiangolo.
0.0.12¶
Features¶
- ✨ Upgrade SQLAlchemy to 2.0. PR #700 by @tiangolo including initial work in PR #563 by @farahats9.
Internal¶
- ⬆ [pre-commit.ci] pre-commit autoupdate. PR #686 by @pre-commit-ci[bot].
- 👷 Upgrade latest-changes GitHub Action. PR #693 by @tiangolo.
0.0.11¶
Features¶
- ✨ Add support for passing a custom SQLAlchemy type to
Field()
withsa_type
. PR #505 by @maru0123-2004.- You might consider this a breaking change if you were using an incompatible combination of arguments, those arguments were not taking effect and now you will have a type error and runtime error telling you that.
- ✨ Do not allow invalid combinations of field parameters for columns and relationships,
sa_column
excludessa_column_args
,primary_key
,nullable
, etc. PR #681 by @tiangolo.
Docs¶
- 🎨 Update inline source examples, hide
#
in annotations (from MkDocs Material). PR #677 by @Matthieu-LAURENT39.
Internal¶
- ⬆ Update coverage requirement from ^6.2 to >=6.2,<8.0. PR #663 by @dependabot[bot].
- ⬆ Update mkdocs-material requirement from 9.1.21 to 9.2.7. PR #675 by @dependabot[bot].
- ⬆️ Upgrade mypy manually. PR #684 by @tiangolo.
- ⬆ Update black requirement from ^22.10.0 to >=22.10,<24.0. PR #664 by @dependabot[bot].
- 👷 Update CI to build MkDocs Insiders only when the secrets are available, for Dependabot. PR #683 by @tiangolo.
0.0.10¶
Features¶
- ✨ Add support for all
Field
parameters from Pydantic1.9.0
and above, make Pydantic1.9.0
the minimum required version. PR #440 by @daniil-berg.
Internal¶
0.0.9¶
Breaking Changes¶
Features¶
Fixes¶
- 🐛 Fix
AsyncSession
type annotations forexec()
. PR #58 by @Bobronium. - 🐛 Fix allowing using a
ForeignKey
directly, remove repeated column construction fromSQLModelMetaclass.__init__
and upgrade minimum SQLAlchemy to>=1.4.36
. PR #443 by @daniil-berg. - 🐛 Fix enum type checks ordering in
get_sqlalchemy_type
. PR #669 by @tiangolo. - 🐛 Fix SQLAlchemy version 1.4.36 breaks SQLModel relationships (#315). PR #461 by @byrman.
Upgrades¶
- ⬆️ Upgrade support for SQLAlchemy 1.4.49, update tests. PR #519 by @sandrotosi.
- ⬆ Raise SQLAlchemy version requirement to at least
1.4.29
(related to #434). PR #439 by @daniil-berg.
Docs¶
- 📝 Clarify description of in-memory SQLite database in
docs/tutorial/create-db-and-table.md
. PR #601 by @SimonCW. - 📝 Tweak wording in
docs/tutorial/fastapi/multiple-models.md
. PR #674 by @tiangolo. - ✏️ Fix contributing instructions to run tests, update script name. PR #634 by @PookieBuns.
- 📝 Update link to docs for intro to databases. PR #593 by @abenezerBelachew.
- 📝 Update docs, use
offset
in example withlimit
andwhere
. PR #273 by @jbmchuck. - 📝 Fix docs for Pydantic's fields using
le
(lte
is invalid, usele
). PR #207 by @jrycw. - 📝 Update outdated link in
docs/db-to-code.md
. PR #649 by @MatveyF. - ✏️ Fix typos found with codespell. PR #520 by @kianmeng.
- 📝 Fix typos (duplication) in main page. PR #631 by @Mr-DRP.
- 📝 Update release notes, add second author to PR. PR #429 by @br-follow.
- 📝 Update instructions about how to make a foreign key required in
docs/tutorial/relationship-attributes/define-relationships-attributes.md
. PR #474 by @jalvaradosegura. - 📝 Update help SQLModel docs. PR #548 by @tiangolo.
- ✏️ Fix typo in internal function name
get_sqlachemy_type()
. PR #496 by @cmarqu. - ✏️ Fix typo in docs. PR #446 by @davidbrochart.
- ✏️ Fix typo in
docs/tutorial/create-db-and-table.md
. PR #477 by @FluffyDietEngine. - ✏️ Fix small typos in docs. PR #481 by @micuffaro.
Internal¶
- ⬆ [pre-commit.ci] pre-commit autoupdate. PR #672 by @pre-commit-ci[bot].
- ⬆ Bump dawidd6/action-download-artifact from 2.24.2 to 2.28.0. PR #660 by @dependabot[bot].
- ✅ Refactor OpenAPI FastAPI tests to simplify updating them later, this moves things around without changes. PR #671 by @tiangolo.
- ⬆ Bump actions/checkout from 3 to 4. PR #670 by @dependabot[bot].
- 🔧 Update mypy config, use
strict = true
instead of manual configs. PR #428 by @michaeloliverx. - ⬆️ Upgrade MkDocs Material. PR #668 by @tiangolo.
- 🎨 Update docs format and references with pre-commit and Ruff. PR #667 by @tiangolo.
- 🎨 Run pre-commit on all files and autoformat. PR #666 by @tiangolo.
- 👷 Move to Ruff and add pre-commit. PR #661 by @tiangolo.
- 🛠️ Add
CITATION.cff
file for academic citations. PR #13 by @sugatoray. - 👷 Update docs deployments to Cloudflare. PR #630 by @tiangolo.
- 👷♂️ Upgrade CI for docs. PR #628 by @tiangolo.
- 👷 Update CI debug mode with Tmate. PR #629 by @tiangolo.
- 👷 Update latest changes token. PR #616 by @tiangolo.
- ⬆️ Upgrade analytics. PR #558 by @tiangolo.
- 🔧 Update new issue chooser to point to GitHub Discussions. PR #546 by @tiangolo.
- 🔧 Add template for GitHub Discussion questions and update issues template. PR #544 by @tiangolo.
- 👷 Refactor CI artifact upload/download for docs previews. PR #514 by @tiangolo.
- ⬆ Bump actions/cache from 2 to 3. PR #497 by @dependabot[bot].
- ⬆ Bump dawidd6/action-download-artifact from 2.24.0 to 2.24.2. PR #493 by @dependabot[bot].
- 🔧 Update Smokeshow coverage threshold. PR #487 by @tiangolo.
- 👷 Move from Codecov to Smokeshow. PR #486 by @tiangolo.
- ⬆ Bump actions/setup-python from 2 to 4. PR #411 by @dependabot[bot].
- ⬆ Update black requirement from ^21.5-beta.1 to ^22.10.0. PR #460 by @dependabot[bot].
- ➕ Add extra dev dependencies for MkDocs Material. PR #485 by @tiangolo.
- ⬆ Update mypy requirement from 0.930 to 0.971. PR #380 by @dependabot[bot].
- ⬆ Update coverage requirement from ^5.5 to ^6.2. PR #171 by @dependabot[bot].
- ⬆ Bump codecov/codecov-action from 2 to 3. PR #415 by @dependabot[bot].
- ⬆ Bump actions/upload-artifact from 2 to 3. PR #412 by @dependabot[bot].
- ⬆ Update flake8 requirement from ^3.9.2 to ^5.0.4. PR #396 by @dependabot[bot].
- ⬆ Update pytest requirement from ^6.2.4 to ^7.0.1. PR #242 by @dependabot[bot].
- ⬆ Bump actions/checkout from 2 to 3.1.0. PR #458 by @dependabot[bot].
- ⬆ Bump dawidd6/action-download-artifact from 2.9.0 to 2.24.0. PR #470 by @dependabot[bot].
- 👷 Update Dependabot config. PR #484 by @tiangolo.
0.0.8¶
Fixes¶
- 🐛 Fix auto detecting and setting
nullable
, allowing overrides in field. PR #423 by @JonasKs and @br-follow. - ♻️ Update
expresion.py
, sync from Jinja2 template, implementinherit_cache
to solve errors like:SAWarning: Class SelectOfScalar will not make use of SQL compilation caching
. PR #422 by @tiangolo.
Docs¶
- 📝 Adjust and clarify docs for
docs/tutorial/create-db-and-table.md
. PR #426 by @tiangolo. - ✏ Fix typo in
docs/tutorial/connect/remove-data-connections.md
. PR #421 by @VerdantFox.
0.0.7¶
Features¶
- ✨ Allow setting
unique
inField()
for a column. PR #83 by @raphaelgibson. - ✨ Update GUID handling to use stdlib
UUID.hex
instead of anint
. PR #26 by @andrewbolster. - ✨ Raise an exception when using a Pydantic field type with no matching SQLAlchemy type. PR #18 by @elben10.
- ⬆ Upgrade constrain for SQLAlchemy = ">=1.4.17,<=1.4.41". PR #371 by @RobertRosca.
- ✨ Add new
Session.get()
parameterexecution_options
. PR #302 by @tiangolo.
Fixes¶
- 🐛 Fix type annotations for
Model.parse_obj()
, andModel.validate()
. PR #321 by @phi-friday. - 🐛 Fix
Select
andSelectOfScalar
to inherit cache to avoid warning:SAWarning: Class SelectOfScalar will not make use of SQL compilation caching
. PR #234 by @rabinadk1. - 🐛 Fix handling validators for non-default values. PR #253 by @byrman.
- 🐛 Fix fields marked as "set" in models. PR #117 by @statt8900.
- 🐛 Fix Enum handling in SQLAlchemy. PR #165 by @chriswhite199.
- 🐛 Fix setting nullable property of Fields that don't accept
None
. PR #79 by @van51. - 🐛 Fix SQLAlchemy version 1.4.36 breaks SQLModel relationships (#315). PR #322 by @byrman.
Docs¶
- 📝 Update docs for models for updating,
id
should not be updatable. PR #335 by @kurtportelli. - ✏ Fix broken variable/typo in docs for Read Relationships,
hero_spider_boy.id
=>hero_spider_boy.team_id
. PR #106 by @yoannmos. - 🎨 Remove unwanted highlight in the docs. PR #233 by @jalvaradosegura.
- ✏ Fix typos in
docs/databases.md
anddocs/tutorial/index.md
. PR #35 by @prrao87. - ✏ Fix typo in
docs/tutorial/relationship-attributes/define-relationships-attributes.md
. PR #239 by @jalvaradosegura. - ✏ Fix typo in
docs/tutorial/fastapi/simple-hero-api.md
. PR #80 by @joemudryk. - ✏ Fix typos in multiple files in the docs. PR #400 by @VictorGambarini.
- ✏ Fix typo in
docs/tutorial/code-structure.md
. PR #344 by @marciomazza. - ✏ Fix typo in
docs/db-to-code.md
. PR #155 by @gr8jam. - ✏ Fix typo in
docs/contributing.md
. PR #323 by @Fardad13. - ✏ Fix typo in
docs/tutorial/fastapi/tests.md
. PR #265 by @johnhoman. - ✏ Fix typo in
docs/tutorial/where.md
. PR #286 by @jalvaradosegura. - ✏ Fix typos in
docs/tutorial/fastapi/update.md
. PR #268 by @cirrusj. - ✏ Fix typo in
docs/tutorial/fastapi/simple-hero-api.md
. PR #247 by @hao-wang. - ✏ Fix typos in
docs/tutorial/automatic-id-none-refresh.md
,docs/tutorial/fastapi/update.md
,docs/tutorial/select.md
. PR #185 by @rootux. - ✏ Fix typo in
docs/databases.md
. PR #177 by @seandlg. - ✏ Fix typos in
docs/tutorial/fastapi/update.md
. PR #162 by @wmcgee3. - ✏ 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 by @moonso. - ✏ Fix typo in
docs/tutorial/fastapi/teams.md
. PR #154 by @chrisgoddard. - ✏ Fix typo variable in example about relationships and
back_populates
, always usehero
instead ofowner
. PR #120 by @onionj. - ✏ Fix typo in
docs/tutorial/fastapi/tests.md
. PR #113 by @feanil. - ✏ Fix typo in
docs/tutorial/where.md
. PR #72 by @ZettZet. - ✏ Fix typo in
docs/tutorial/code-structure.md
. PR #91 by @dhiraj. - ✏ Fix broken link to newsletter sign-up in
docs/help.md
. PR #84 by @mborus. - ✏ Fix typos in
docs/tutorial/many-to-many/create-models-with-link.md
. PR #45 by @xginn8. - ✏ Fix typo in
docs/tutorial/index.md
. PR #398 by @ryangrose.
Internal¶
- ♻ Refactor internal statements to simplify code. PR #53 by @yezz123.
- ♻ Refactor internal imports to reduce redundancy. PR #272 by @aminalaee.
- ⬆ Update development requirement for FastAPI from
^0.68.0
to^0.68.1
. PR #48 by @alucarddelta. - ⏪ Revert upgrade Poetry, to make a release that supports Python 3.6 first. PR #417 by @tiangolo.
- 👷 Add dependabot for GitHub Actions. PR #410 by @tiangolo.
- ⬆️ Upgrade Poetry to version
==1.2.0b1
. PR #303 by @tiangolo. - 👷 Add CI for Python 3.10. PR #305 by @tiangolo.
- 📝 Add Jina's QA Bot to the docs to help people that want to ask quick questions. PR #263 by @tiangolo.
- 👷 Upgrade Codecov GitHub Action. PR #304 by @tiangolo.
- 💚 Only run CI on push when on master, to avoid duplicate runs on PRs. PR #244 by @tiangolo.
- 🔧 Upgrade MkDocs Material and update configs. PR #217 by @tiangolo.
- ⬆ Upgrade mypy, fix type annotations. PR #218 by @tiangolo.
0.0.6¶
Breaking Changes¶
SQLModel no longer creates indexes by default for every column, indexes are now opt-in. You can read more about it in PR #205.
Before this change, if you had a model like this:
from typing import Optional
from sqlmodel import Field, SQLModel
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str
secret_name: str
age: Optional[int] = None
...when creating the tables, SQLModel version 0.0.5
and below, would also create an index for name
, one for secret_name
, and one for age
(id
is the primary key, so it doesn't need an additional index).
If you depended on having an index for each one of those columns, now you can (and would have to) define them explicitly:
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str = Field(index=True)
secret_name: str = Field(index=True)
age: Optional[int] = Field(default=None, index=True)
There's a high chance you don't need indexes for all the columns. For example, you might only need indexes for name
and age
, but not for secret_name
. In that case, you could define the model as:
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str = Field(index=True)
secret_name: str
age: Optional[int] = Field(default=None, index=True)
If you already created your database tables with SQLModel using versions 0.0.5
or below, it would have also created those indexes in the database. In that case, you might want to manually drop (remove) some of those indexes, if they are unnecessary, to avoid the extra cost in performance and space.
Depending on the database you are using, there will be a different way to find the available indexes.
For example, let's say you no longer need the index for secret_name
. You could check the current indexes in the database and find the one for secret_name
, it could be named ix_hero_secret_name
. Then you can remove it with SQL:
DROP INDEX ix_hero_secret_name
or
DROP INDEX ix_hero_secret_name ON hero;
Here's the new, extensive documentation explaining indexes and how to use them: Indexes - Optimize Queries.
Docs¶
- ✨ Document indexes and make them opt-in. Here's the new documentation: Indexes - Optimize Queries. This is the same change described above in Breaking Changes. PR #205 by @tiangolo.
- ✏ Fix typo in FastAPI tutorial. PR #192 by @yaquelinehoyos.
- 📝 Add links to the license file. PR #29 by @sobolevn.
- ✏ Fix typos in docs titles. PR #28 by @Batalex.
- ✏ Fix multiple typos and some rewording. PR #22 by @egrim.
- ✏ Fix typo in
docs/tutorial/automatic-id-none-refresh.md
. PR #14 by @leynier. - ✏ Fix typos in
docs/tutorial/index.md
anddocs/databases.md
. PR #5 by @sebastianmarines.
0.0.5¶
Features¶
- ✨ Add support for Decimal fields from Pydantic and SQLAlchemy. Original PR #103 by @robcxyz. New docs: Advanced User Guide - Decimal Numbers.
Docs¶
Internal¶
- 🔧 Split MkDocs insiders build in CI to support building from PRs. PR #186 by @tiangolo.
- 🎨 Format
expression.py
and expression template, currently needed by CI. PR #187 by @tiangolo. - 🐛Fix docs light/dark theme switcher. PR #1 by @Lehoczky.
- 🔧 Add MkDocs Material social cards. PR #90 by @tiangolo.
- ✨ Update type annotations and upgrade mypy. PR #173 by @tiangolo.
0.0.4¶
0.0.3¶
0.0.2¶
- This includes several small bug fixes detected during the first CI runs.
- 💚 Fix CI installs and tests. PR #2 by @tiangolo.
0.0.1¶
- First release. 🎉