89 Commits

Author SHA1 Message Date
John Lyu
dbd0101c40 fix default value is InstrumentedAttribute in inherit 2025-02-05 10:21:13 +08:00
John Lyu
0efd1bfaa0 remove effort of pydantic v1 2024-12-03 18:08:01 +08:00
John Lyu
66c1d93cfe lint 2024-12-03 18:04:46 +08:00
John Lyu
015601cd5b improve code structure 2024-12-03 17:59:21 +08:00
John Lyu
4aade03081 fix type hint for <3.10 2024-11-26 11:22:05 +08:00
John Lyu
277953a614 fix pydantic v1 support 2024-11-26 11:19:28 +08:00
John Lyu
e6ad74d50a fix lint 2024-11-26 11:17:55 +08:00
John Lyu
48f2a88752 fix polymorphic_on check 2024-11-26 10:57:07 +08:00
John Lyu
4071b0fc64 fix polymorphic_on check 2024-11-26 10:54:26 +08:00
John Lyu
589237b80f improve docs 2024-11-26 10:51:53 +08:00
John Lyu
6d93a46fe0 support sqlalchemy polymorphic 2024-11-26 10:43:13 +08:00
Sebastián Ramírez
aa814e24bc
🚨 Fix types for new Pydantic (#1131) 2024-10-07 21:21:59 +00:00
Sebastián Ramírez
016b2baaad 🔖 Release version 0.0.22 2024-08-31 11:40:12 +02:00
Sebastián Ramírez
a14ab0bd3c
🐛 Fix support for types with Optional[Annoated[x, f()]], e.g. id: Optional[pydantic.UUID4] (#1093) 2024-08-31 11:38:19 +02:00
Sebastián Ramírez
458e088170 🔖 Release version 0.0.21 2024-07-20 21:10:30 -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
Sebastián Ramírez
b8d7f4ff67 🔖 Release version 0.0.20 2024-07-16 21:53:24 -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
Anderson T
e7c62fc9d9
✏️ Fix typo in sqlmodel/_compat.py (#950) 2024-06-04 18:56:52 -05:00
Sebastián Ramírez
4590963e88 🔖 Release version 0.0.19 2024-06-03 22:26:53 -05:00
Sebastián Ramírez
b560e9deb8
⬆️ Upgrade Ruff and Black (#968)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-03 22:22:04 -05:00
Esteban Maya
1d43bd8b1e
🐛 Fix pydantic EmailStr support and max_length in several String subclasses (#966) 2024-06-03 21:47:40 -05:00
Sebastián Ramírez
d165e4b5ad
♻️ Refactor generate select template to isolate templated code to the minimum (#967)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-03 21:34:54 -05:00
Esteban Maya
5bb4cffd49
🐛 Fix set varchar limit when max_length is set on Pydantic models using Pydantic v2 (#963)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-06-04 00:39:23 +00:00
Sebastián Ramírez
900e0d3371 🔖 Release version 0.0.18 2024-04-29 23:25:02 -07:00
Sebastián Ramírez
9ebbf255f7
Add sqlmodel-slim setup (#916) 2024-04-30 06:22:28 +00:00
Sebastián Ramírez
0431c5bb26 🔖 Release version 0.0.17 2024-04-29 16:44:21 -07:00
Sebastián Ramírez
0b4989d0b2
🔧 Migrate from Poetry to PDM for the internal build config (#912) 2024-04-29 15:58:15 -07:00
Sebastián Ramírez
2454694de3
♻️ Refactor types to properly support Pydantic 2.7 (#913) 2024-04-29 15:11:02 -07:00
Sebastián Ramírez
6b562358fc 🔖 Release version 0.0.16 2024-02-17 14:53:16 +01: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
7fec884864 🔖 Release version 0.0.15 2024-02-17 14:36:12 +01:00
Sebastián Ramírez
1b7b3aa668
🐛 Fix class initialization compatibility with Pydantic and SQLModel, fixing errors revealed by the latest Pydantic (#807) 2024-02-17 13:34:57 +00:00
Sebastián Ramírez
8419545a3a
👷 Fix GitHub Actions build docs filter paths for GitHub workflows (#738)
* 👷 Fix GitHub Actions build docs filter paths for GitHub workflows

* 🎨 Update format of expression and conftest
2023-12-10 20:19:12 +00:00
Sebastián Ramírez
b892504141 🔖 Release version 0.0.14 2023-12-04 15:51:20 +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
5b733b348d 🔖 Release version 0.0.13 2023-12-04 13:15:10 +01:00
Sebastián Ramírez
853d787923
♻️ Refactor type generation of selects re-order to prioritize models to optimize editor support (#718) 2023-12-04 09:46:59 +00:00
Sebastián Ramírez
4ac87146b1
🔇 Do not raise deprecation warnings for execute as it's automatically used internally (#716)
* 🔇 Do not raise deprecation warnings for execute as it's automatically used internally

*  Tweak tests to not use deprecated query
2023-11-30 15:23:06 +00:00
Sebastián Ramírez
b1c2f822c9 🔖 Release version 0.0.12 2023-11-18 12:32:59 +01:00
Sebastián Ramírez
8ed856d322
Upgrade SQLAlchemy to 2.0, including initial work by farahats9 (#700)
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>
2023-11-18 12:30:37 +01:00
Sebastián Ramírez
dacc1fa9ca 🔖 Release version 0.0.11 2023-10-29 13:56:39 +04:00
Maruo.S
cbaf172c63
Add support for passing a custom SQLAlchemy type to Field() with sa_type (#505)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-10-29 12:10:39 +04:00
Sebastián Ramírez
717594ef13
Do not allow invalid combinations of field parameters for columns and relationships, sa_column excludes sa_column_args, primary_key, nullable, etc. (#681)
* ♻️ Make sa_column exclusive, do not allow incompatible arguments, sa_column_args, primary_key, etc

*  Add tests for new errors when incorrectly using sa_column

*  Add tests for sa_column_args and sa_column_kwargs

* ♻️ Do not allow sa_relationship with sa_relationship_args or sa_relationship_kwargs

*  Add tests for relationship errors

*  Fix test for sa_column_args
2023-10-28 17:55:23 +04:00
Sebastián Ramírez
e4e1385eed 🔖 Release version 0.0.10 2023-10-26 18:34:49 +04:00
Daniil Fajnberg
99f8ce3894
Add support for all Field parameters from Pydantic 1.9.0 and above, make Pydantic 1.9.0 the minimum required version (#440)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-10-26 14:18:05 +04:00
Sebastián Ramírez
d05c3ee495 🔖 Release version 0.0.9 2023-10-24 01:01:18 +04:00
Arseny Boykov
9732c5ac60
🐛 Fix AsyncSession type annotations for exec() (#58)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-10-23 18:58:16 +04:00
Daniil Fajnberg
9809b5bc83
🐛 Fix allowing using a ForeignKey directly, remove repeated column construction from SQLModelMetaclass.__init__ and upgrade minimum SQLAlchemy to >=1.4.36 (#443)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-10-23 17:59:06 +04:00
Sebastián Ramírez
d3261cab59
🐛 Fix enum type checks ordering in get_sqlalchemy_type (#669)
Co-authored-by: Pierre Cheynier <p.cheynier@criteo.com>
2023-10-23 13:22:44 +04:00