24 Commits

Author SHA1 Message Date
Sebastián Ramírez
ee44f3b85e
📝 Update admonitions in annotations (#1065) 2024-08-12 16:38:19 -05:00
Esteban Maya
86ab09f7ec
Add support for cascade delete relationships: cascade_delete, ondelete, and passive_deletes (#983)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-07-20 21:08:06 -05:00
Esteban Maya
95936bb508
Add official UUID support, docs and tests, internally using new SQLAlchemy 2.0 types (#992)
*  Add UUID support from sqlalchemy 2.0 update

* ⚰️ Remove dead code for GUID old support

* 📝 Add documentation for UUIDs

* 🧪 Add test for UUIDs field definition and support

* 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks

* ✏️ Fix prerequisites docs for uuid

* ♻️ Update UUID source examples for consistency

Keep consistency with other examples, functions without parameters, and printing info that shows and explains the UUID results (and can also be tested later)

* 📝 Add source examples for selecting UUIDs with session.get()

* 📝 Re-structure UUID docs

* Explain the concepts at the beggining before using them.
* Explain how UUIDs can be used and trusted.
* Explain why UUIDs could be generated on the code, and how they can be used for distributed systems.
* Explain how UUIDs can prevent information leakage.
* Warn about UUIDs storage size.
* Explain that uuid is part of the standard library.
* Explain how default_factory works.
* Explain that creating an instance would generate a new UUID, before it is sent to the DB. This is included and shown in the example, the UUID is printed before saving to the DB.
* Remove sections about other operations that would behave the same as other fields and don't need additional info from what was explained in previous chapters.
* Add two examples to select using UUIDs, similar to the previous ones, mainly to be able to use them in the tests and ensure that it all works, even when SQLite stores the values as strings but the where() or the session.get() receive UUID values (ensure SQLAlchemy does the conversion correctly for SQLite).
* Add an example terminal run of the code, with comments.
* Simplify the ending to keep only the information that wasn't there before, just the "Learn More" with links.

*  Refactor tests with new printed code, extract and check that UUIDs are used in the right places.

*  Add tests for the new extra UUID examples, for session.get()

* 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks

* 📝 Rename variable in example for Python 3.7+ for consistency with 3.10+ (I missed that change before)

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-07-16 20:52:03 -05:00
Esteban Maya
1eb40b1f33
📝 Update ModelRead to ModelPublic documentation and examples (#885)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-04-08 18:07:48 -05:00
Sebastián Ramírez
9141c8a920
Add source examples for Python 3.10 and 3.9 with updated syntax (#842)
Co-authored-by: Esteban Maya Cadavid <emayacadavid9@gmail.com>
2024-03-21 17:49:38 -05:00
Sebastián Ramírez
fa12c5d87b
Add new method sqlmodel_update() to update models in place, including an update parameter for extra data (#804) 2024-02-17 14:49:39 +01:00
Sebastián Ramírez
fa2f178b8a
Add support for Pydantic v2 (while keeping support for v1 if v2 is not available), including initial work by AntonDeMeester (#722)
Co-authored-by: Mohamed Farahat <farahats9@yahoo.com>
Co-authored-by: Stefan Borer <stefan.borer@gmail.com>
Co-authored-by: Peter Landry <peter.landry@gmail.com>
Co-authored-by: Anton De Meester <antondemeester+github@gmail.com>
2023-12-04 15:42:39 +01:00
Sebastián Ramírez
5c0fca1d96
✏️ Fix typo, simplify single quote/apostrophe character in "Sister Margaret's" everywhere in the docs (#721) 2023-12-04 13:13:03 +01:00
Sebastián Ramírez
41495e30c7
📝 Update docs for Decimal, use proper types (#719) 2023-12-04 09:49:23 +00:00
Sebastián Ramírez
d8effcbc5c
📝 Add source examples for Python 3.9 and 3.10 (#715)
* 📝 Add source examples for Python 3.9 and 3.10

*  Add tests for new source examples for Python 3.9 and 3.10, still needs pytest markers

*  Add tests for fastapi examples

*  Update tests for FastAPI app testing, for Python 3.9 and 3.10, fixing multi-app testing conflicts

*  Require Python 3.9 and 3.10 for tests

*  Update tests with missing markers
2023-11-29 16:51:55 +01:00
Matthieu LAURENT
9632980664
🎨 Update inline source examples, hide # in annotations (from MkDocs Material) (#677)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-10-29 07:24:32 +00:00
Jon Michaelchuck
403d44ea78
📝 Update docs, use offset in example with limit and where (#273)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-10-23 20:55:53 +04:00
Jerry Wu
d192142eb9
📝 Fix docs for Pydantic's fields using le (lte is invalid, use le ) (#207)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-10-23 16:28:51 +00:00
Sebastián Ramírez
56f43904c1
🎨 Update docs format and references with pre-commit and Ruff (#667) 2023-10-23 08:11:36 +00:00
Sebastián Ramírez
27a81b2112
🎨 Run pre-commit on all files and autoformat (#666) 2023-10-23 11:46:31 +04:00
Kian-Meng Ang
1568bad01e
✏️ Fix typos found with codespell (#520)
Found via `codespell -S *.svg,*.css,*.js,*.drawio -L pullrequest,sesion`
2023-10-22 16:50:44 +04:00
kurtportelli
a2cda8377f
📝 Update docs for models for updating, id should not be updatable (#335)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-08-28 01:43:42 +02:00
Yoann Mosteiro
ee576ab279
✏ Fix broken variable/typo in docs for Read Relationships, hero_spider_boy.id => hero_spider_boy.team_id (#106)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-08-27 22:06:56 +00:00
Saman Nezafat
d032c3cfea
✏ Fix typo variable in example about relationships and back_populates, always use hero instead of owner (#120)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-08-27 20:40:57 +00:00
Sebastián Ramírez
155c6178cd
Document indexes and make them opt-in (#205) 2021-12-28 11:48:03 +01:00
Sebastián Ramírez
95c02962ba
✏ Update decimal tutorial source for consistency (#188) 2021-12-13 11:37:59 +00:00
robcxyz
580f372059
Add support for Decimal fields from Pydantic and SQLAlchemy (#103)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2021-12-13 12:30:20 +01:00
Sebastián Ramírez
dc331f649c 📝 Add docs annotations for source examples 2021-08-24 14:51:14 +02:00
Sebastián Ramírez
e6308146f7 Add source examples for docs 2021-08-24 14:50:16 +02:00