Up to [cvs.NetBSD.org] / pkgsrc / databases / py-tortoise-orm
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
py-tortoise-orm: updated to 1.1.2
1.1.2
Fixed
Fixed optimisation issue, if you didn't have pydantic installed, Tortoise would try to import it on every JSONField deserialization, lowering performance.
1.1.1
Added
SqlDefault and Now expressions for db_default — use db_default=SqlDefault("...") to emit raw SQL expressions (e.g. CURRENT_TIMESTAMP) as database defaults. Now() is a convenience shorthand for SqlDefault("CURRENT_TIMESTAMP").
Changed
Field(default=...) and auto_now / auto_now_add no longer emits a DEFAULT clause in generate_schemas(). The default parameter is Python-only; use db_default for database-level defaults. This aligns generate_schemas() with migrations, which don't emitted DEFAULT for default=.
1.1.0
Added
db_default parameter for fields — set database-level DEFAULT clauses that propagate to schema generation and migrations. Unlike default (Python-only), db_default is persisted in the DB schema and applied even for rows inserted outside the ORM.
Model.construct() classmethod for building model instances without field validation — useful in test factories and fixtures.
truncate_all_models() now respects foreign key constraints using topological ordering (SQLite/MySQL) or TRUNCATE ... CASCADE (PostgreSQL).
Auto-recreate database connection when event loop changes. Enables easier testing without session level fixtures
Fixed
Type checking of None assignment to nullable fields.
Fix set global fallback default in Sanic register_tortoise.
Escape [ ] for db url parsing.
Fix UnicodeEncodeError by using UTF-8 encoding for migration files.
py-tortoise-orm: updated to 1.0.0 1.0.0 Breaking Changes Minimum Python version raised to 3.10 (was 3.9). ``use_tz`` now defaults to ``True`` (was False). Set use_tz=False explicitly if you need naive datetimes. Context-first architecture: All ORM state now lives in TortoiseContext instances. Tortoise.init() returns a TortoiseContext (previously returned None). Multiple separate asyncio.run() calls require explicit context management; the typical single asyncio.run(main()) pattern works unchanged. Removed legacy test infrastructure: test.TestCase, test.IsolatedTestCase, test.TruncationTestCase, test.SimpleTestCase, initializer(), finalizer(), env_initializer(), getDBConfig(). Use tortoise_test_context() with pytest instead. Removed ``pytz`` dependency: Timezone handling now uses the standard library zoneinfo module. Tortoise APIs return ZoneInfo objects instead of pytz timezones. ``DatetimeField``/``TimeField`` with ``auto_now=True`` no longer implicitly sets auto_now_add=True. In practice auto_now=True alone still sets the value on every save (including creation), so this is unlikely to affect most users. The internal flag coupling was removed for correctness. Shell extras required: Interactive shell dependencies are now optional. Install with pip install tortoise-orm[ipython] or pip install tortoise-orm[ptpython]. Added Native migrations framework with CLI commands: tortoise makemigrations, tortoise migrate, tortoise sqlmigrate. Supports RunPython, RunSQL, reversible migrations, and multi-app projects. Database schema support for PostgreSQL and MSSQL (on MySQL maps to database name) — tables can live in non-default schemas (e.g., warehouse.inventory), with cross-schema relations and migration support. PostgreSQL full-text search: TSVectorField, SearchVector, SearchQuery, SearchRank, SearchHeadline expressions, and GIN/GiST index support. Query API (tortoise.query_api) for building and executing custom pypika queries against models, with Model.get_table() classmethod. TortoiseContext — explicit context manager for ORM state with full isolation. tortoise_test_context() — modern pytest fixture helper for test isolation. get_connection(alias) / get_connections() — functions to access connections from current context. Tortoise.close_connections() — restored (was deprecated in 0.19) as the canonical way to close connections, now context-aware. Tortoise.is_inited() — explicit method version of Tortoise._inited property. ForeignKeyField and ManyToManyField now accept a model class directly, not just string references. DateField now supports __year / __month / __day filters. Changed Framework integrations (FastAPI, Starlette, Sanic, etc.) now use Tortoise.close_connections() internally. ConnectionHandler uses per-instance ContextVar storage for context isolation. Tortoise.apps and Tortoise._inited are now classproperty descriptors. Performance optimizations for model hydration, object construction, and query building. Pydantic model creator internals cleaned up: removed legacy validator, improved computed field handling. Deprecated from tortoise import connections — use get_connection() / get_connections() instead (still works but deprecated). Fixed use_tz=False now correctly preserves naive datetimes instead of silently making them timezone-aware. Annotations incorrectly selected in ValuesListQuery when not specified in .values_list() fields. M2M filtering broken when two relations point to the same target model. Pydantic incorrectly marking fields with default values as Optional. Model.in_bulk type annotation now supports any primary key type. Migration bug fixes: field serialization, operation ordering, and sqlmigrate command added.
py-tortoise-orm: updated to 0.25.2 0.25.2 Fixed Fix grouping by in subqueries Fix sqlite decimal filter error with __gt Changed Official support python3.14 Migrate from poetry to uv Reorder imports by ruff Migrate lint tool from isort+black to ruff Added Add create() method to reverse ForeignKey relations, enabling parent.children.create() syntax
py-tortoise-orm: fix for latest poetry-core Bump PKGREVISION.
py-tortoise-orm: updated to 0.24.1 0.24.1 Added - Implement __contains, __contained_by, __overlap and __len for ArrayField Fixed - Fix update pk field raises unfriendly error - Using `.distinct()` with an annotation and `.order_by()` produces invalid SQL for PostgreSQL
py-tortoise-orm: updated to 0.24.0 0.24.0 Fixed - Rename pypika to pypika_tortoise for fixing package name conflict - Concurrent connection pool initialization - `_get_dialects`: support properties Changed - Drop support for Python3.8 - Optimize field conversion to database format to speed up `create` and `bulk_create` - Improved query performance by optimizing SQL generation 0.23.0 Added - Implement savepoints for transactions - Added type validation for foreign key fields to ensure type safety. Now raises `ValidationError` when assigning foreign key values with incorrect model types Fixed - Fixed a deadlock in three level nested transactions - Fix backward_relations in PydanticMeta
py-tortoise-orm: fix PLIST for latest poetry-core Bump PKGREVISION
py-tortoise-orm: updated to 0.22.0 0.22.0 Fixed - Fix enums not quoted, allowing using of str enums for filters - Primary key field should not be nullable in pydantic schema - Fix ambiguous column name when grouping with joining - Fix same model returned by pydantic_model_creator calls with different arguments Added - JSONField adds optional generic support, and supports OpenAPI document generation by specifying `field_type` as a pydantic BaseModel - Add table_name_generator attribute to Tortoise.init for dynamic table name generation - Support for annotation and joins F() expressions - Allow use of annotate fields within Case-When expression - Added new queryset methods: last(), latest(), earliest() Changed - Change old pydantic docs link to new one - Refactored pydantic_model_creator, interface not changed - Values are no longer validated to be right type upon loading from database - Refactored private field names in queryset classes
py-tortoise-orm: updated to 0.21.7 0.21.7 Fixed - Fix unittest error with pydantic2.9 - Fix bug when using annotate and count at the same time but the annotation does not match anything, leading to an IndexError - Added missing field_type for TimeDeltaField - improve jsonfield type hint - Fix bug in tortoise.models.Model When a QuerySet uses the only function and then uses the print function to print the returned result, an AttributeError is generated - Update the pylint plugin to latest astroid version Added - Add POSIX Regex support for PostgreSQL and MySQL - support app=None for tortoise.contrib.fastapi.RegisterTortoise
py-tortoise-orm: updated to 0.20.0 0.20.0 ------ Added ^^^^^ - Allow ForeignKeyField(on_delete=NO_ACTION) - Support `pydantic` 2.0. Fixed ^^^^^ - Fix foreign key constraint not generated on MSSQL Server. - Fix testcase error with python3.11 Breaking Changes ^^^^^^^^^^^^^^^^ - Drop support for `pydantic` 1.x. - Drop support for `python` 3.7. - Param `config_class` of `pydantic_model_creator` is renamed to `model_config`. - Attr `config_class` of `PydanticMeta` is renamed to `model_config`. 0.19 ==== 0.19.3 ------ Added ^^^^^ - Added config_class option to pydantic model genator that allows the developer to customize the generated pydantic model's `Config` class. Fixed ^^^^^ - Fastapi example test not working. - Fix create index sql error. - Fix dependencies resolve error. - Fix ignoring zero value of limit. - Fix ForeignKeyField is none when fk is integer 0. - Fix limit ignore zero. - Fix min/max value validators for decimal fields. 0.19.2 ------ Added ^^^^^ - Added `schema` attribute to Model's Meta to specify exact schema to use with the model. Fixed ^^^^^ - Mixin does not work. - `using_db` wrong position in model shortcut methods. - Fixed connection to `Oracle` database by adding database info to DBQ in connection string. - Fixed ORA-01435 error while using `Oracle` database - Fixed processing of `ssl` option in MySQL connection string. - Fixed type hinting for `QuerySetSingle`. 0.19.1 ------ Added ^^^^^ - Added `Postgres`/`SQLite` partial indexes support. - Added `Microsoft SQL Server`/`Oracle` support, powered by `asyncodbc <https://github.com/tortoise/asyncodbc>`_, note that which is **not fully tested**. - Added `optional` parameter to `pydantic_model_creator`. - Added `using_db` parameter to `Model` shortcut methods. Fixed ^^^^^ - `TimeField` for `MySQL` will return `datetime.timedelta` object instead of `datetime.time` object. - Fix on conflict do nothing. - Fix `_custom_generated_pk` attribute not set in `Model._init_from_db` method. 0.19.0 ------ Added ^^^^^ - Added psycopg backend support. - Added a new unified and robust connection management interface to access DB connections which includes support for lazy connection creation and much more. For more details, check out this `PR <https://github.com/tortoise/tortoise-orm/pull/1001>`_ - Added `TimeField`. - Added `ArrayField`. Fixed ^^^^^ - Fix `bulk_create` doesn't work correctly with more than 1 update_fields. - Fix `bulk_update` errors when setting null for a smallint column on postgres. Deprecated ^^^^^^^^^^ - Existing connection management interface and related public APIs which are deprecated: - `Tortoise.get_connection` - `Tortoise.close_connections` Changed ^^^^^^^ - Refactored `tortoise.transactions.get_connection` method to `tortoise.transactions._get_connection`. Note that this method has now been marked **private to this module and is not part of the public API**
py-tortoise-orm: updated to 0.16.20 0.16.20 - Add model field validators. - Allow function results in group by.
py-tortoise-orm: updated to 0.16.18 0.16.18 Support custom function in update. Add Model.refresh_from_db. Add timezone support, be careful to upgrade to this version, see docs for details. Remove aerich in case of cyclic dependency.
py-tortoise-orm: updated to 0.16.15 0.16.15 Make DateField accept valid date str. Add QuerySet.select_for_update(). check default for not None on pydantic model creation propagate default to pydantic model Add QuerySet.select_related(). Add custom attribute name for Prefetch instruction. Add db_constraint for RelationalField family.
py-tortoise-orm: updated to 0.16.14 0.16.14 Make F expression work with QuerySet.filter(). Include py.typed in source distribution. Added datetime parsing from int for fields.DatetimeField. get_or_create passes the using_db= on if provided. Allow custom loop and connection_class parameters to be passed on to asyncpg.
py-tortoise-orm: added version 0.16.12 Tortoise ORM is an easy-to-use asyncio ORM (Object Relational Mapper) inspired by Django. Tortoise ORM was build with relations in mind and admiration for the excellent and popular Django ORM. It's engraved in it's design that you are working not with just tables, you work with relational data.