Skip to content

fix(deps): upgrade dependency tortoise-orm to v1 - #1

Open
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/tortoise-orm-1.x
Open

fix(deps): upgrade dependency tortoise-orm to v1#1
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/tortoise-orm-1.x

Conversation

@renovate

@renovate renovate Bot commented May 23, 2026

Copy link
Copy Markdown

This PR contains the following updates:

Package Change Age Confidence
tortoise-orm >=0.25.4,<1.0.0>=1.1.8,<1.2.0 age confidence

Release Notes

tortoise/tortoise-orm (tortoise-orm)

v1.1.8

Compare Source

Added
^^^^^

  • QuerySet.union() — SQL UNION query support for combining results from multiple QuerySets, including support for union across different models, union(all=True) for duplicates, order_by(), limit(), and count(). (#​2146)
  • feat: add postgresql:// scheme as alias for asyncpg (#​2154)
  • feat: add pre commit config and fix codespell issues (#​2159)
  • feat: django compatibility field name (#​2160)
  • feat: expose classmethod to build tortoise config (#​2162)
  • QuerySet.contains() method to check if an object exists in a queryset. (#​2163)
  • Added comprehensive EXPLAIN support for MySQL and PostgreSQL. (#​2165)
  • Built-in DomainNameValidator, URLValidator, and EmailValidator classes for common validation patterns. (#​2167)

Fixed
^^^^^

  • MigrationRecorder now uses parameterized queries; fixes MariaDB/MySQL rejecting ISO-8601 applied_at values. (#​2132)
  • fix(migrations): use parameterized queries in MigrationRecorder (#​2153)
  • Applies model generics on relational fields functions (#​2156)
  • fix: MSSQL connection left in busy state after insert (#​2171)
  • db_default on ForeignKeyField/OneToOneField now propagates to the underlying <fk>_id column, so CREATE TABLE emits the DEFAULT clause for FK columns. (#​2199)
  • Fix db_default on FK/O2O dropped during _init_relations (#​2200)
  • MigrationRecorder no longer emits tortoise's own pk field DeprecationWarning when applying migrations; it now builds its bookkeeping model with primary_key=True. (#​2203)
  • QuerySet.count() now matches the limited query result for the LIMIT/OFFSET edge cases: it returns 0 (instead of a negative number) when offset() exceeds the total row count, and 0 (instead of the total) for limit(0). (#​2208)
  • tests: cover Q inequality and unhashable behavior (#​2214)
  • Field declarations on models now resolve to their concrete type (e.g. CharField[str]) in Pyright/Pylance instead of Field[Unknown]; the Field.__new__ type-check stub now returns Self. (#​2216)
  • Type hint for TransactionContext now returns a TransactionalDBClient instead of a raw database connection. This change gives the correct inferred type for the transaction context. (#​2232)
  • Fix TSVectorField returned value conversion. (#​2237)

v1.1.7

Compare Source

Added
^^^^^

  • QuerySet.union() — SQL UNION query support for combining results from multiple QuerySets, including support for union across different models, union(all=True) for duplicates, order_by(), limit(), and count().
  • Tests for model validators. (#​2137)

Fixed
^^^^^

  • Reorder delete model operations in migrations to avoid foreign key constraint errors. (#​2145)
  • Return value generated by db_default on create instead of None. (#​2143)
  • Column comment alteration now works correctly for MySQL and PostgreSQL; fixed db_default handling for MySQL. (#​2142)
  • Fix docstrings for a few classes. (#​2135)

Changed
^^^^^^^

  • Improved Pydantic JSON dump performance. (#​2130)

v1.1.6

Compare Source

Fixed
^^^^^

  • Migration generator now correctly orders AddIndex, RemoveIndex, AddConstraint, RemoveConstraint operations when adding/removing a field to a model that is used in an index or constraint. (#​2118)
  • CreateModel migrations now include DEFAULT clauses for fields with db_default set. Previously only AddField emitted defaults correctly. (#​2129)
  • AlterField migrations now detect max_length changes (e.g. VARCHAR(32)VARCHAR(64)) and emit the correct ALTER statements across all backends. (#​2128)
  • backward_relations=False in PydanticMeta now only excludes unannotated backward relations — fields explicitly annotated with ReverseRelation in the model class body are preserved. (#​2125)
  • MySQL session time_zone now uses the configured timezone instead of always defaulting to +0:00 when use_tz=True. (#​2127)
  • Plus sign (+) in database URL passwords is no longer incorrectly decoded as a space. (#​2123)

v1.1.5

Compare Source

Fixed
^^^^^

  • makemigrations no longer crashes with AttributeError: 'tuple' object has no attribute 'deconstruct' when generating a fresh CreateModel migration for models using tuple-style Meta.indexes (e.g. indexes = [("field_a", "field_b")]). Tuple entries are now normalised to Index objects before rendering.

v1.1.4

Compare Source

Added
^^^^^

  • CheckConstraint support in Meta.constraints — named check constraints are now captured by the migration autodetector, enabling AddConstraint/RemoveConstraint/RenameConstraint generation via makemigrations.
  • UniqueConstraint.condition parameter for partial unique indexes on PostgreSQL (emitted as CREATE UNIQUE INDEX ... WHERE).

Fixed
^^^^^

  • FK field-to-column resolution in constraint operations — FK fields like organization are now correctly resolved to their DB column (e.g. organization_id) in add_constraint, remove_constraint, and rename_constraint across all backends.
  • MSSQL HASHBYTES expression default — RandomHex now wraps NEWID() with CAST(... AS NVARCHAR(36)) to avoid implicit conversion error.
  • MySQL ALTER COLUMN SET DEFAULT template now wraps expression defaults in parentheses.
  • RenameConstraint operation now preserves constraint type and fields during forward/backward migrations.
  • MySQL schema editor: FK index protection (_create_missing_fk_index) prevents MySQL error 1553 when dropping the only index covering a foreign key column.
  • MySQL schema editor: expression default two-step workaround for ADD COLUMN with non-deterministic SqlDefault expressions (e.g. RANDOM_BYTES).
  • Multi-column constraint introspection — constraint name resolution now matches on the exact set of columns across all backends (PostgreSQL, MySQL, MSSQL, SQLite, Oracle).
  • Tortoise.close_connections() now propagates call to current context. (#​2110)

v1.1.3

Compare Source

Added
^^^^^

  • RandomHex dialect-aware SqlDefault subclass for generating random hex strings across all backends. (#​2108)
  • Meta.constraints support on models — named UniqueConstraint objects are now captured by the migration autodetector, enabling AddConstraint/RemoveConstraint generation via makemigrations. (#​2108)
  • MySQL schema editor: _alter_field override using MODIFY COLUMN for NULL/NOT NULL changes; backtick-quoted ALTER_FIELD_* templates. (#​2108)
  • MSSQL schema editor: _alter_field override with ALTER COLUMN for nullability, named default constraint management via sys.default_constraints, bracket-quoted templates, and self-referencing FK CASCADE → NO ACTION downgrade. (#​2108)

Fixed
^^^^^

  • MySQL migrations: ALTER COLUMN ... SET NOT NULL / DROP NOT NULL now correctly emits MODIFY COLUMN col type NOT NULL/NULL. (#​2108)
  • MSSQL migrations: DELETE_CONSTRAINT_TEMPLATE and UNIQUE_CONSTRAINT_CREATE_TEMPLATE now use bracket quoting [name] instead of double quotes. (#​2108)
  • MSSQL migrations: self-referencing foreign keys with CASCADE no longer fail with error 1785; automatically downgraded to NO ACTION. (#​2108)

v1.1.2

Compare Source

Fixed
^^^^^

  • Fixed optimisation issue, if you didn't have pydantic installed, Tortoise would try to import it on every JSONField deserialization, lowering performance.

v1.1.1

Compare Source

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"). (#​2104)

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=. (#​2104)

v1.1.0

Compare Source

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. (#​2101)
  • Model.construct() classmethod for building model instances without field validation — useful in test factories and fixtures. (#​2099)
  • truncate_all_models() now respects foreign key constraints using topological ordering (SQLite/MySQL) or TRUNCATE ... CASCADE (PostgreSQL). (#​2100)
  • Auto-recreate database connection when event loop changes. Enables easier testing without session level fixtures (#​2098)

Fixed
^^^^^

  • Type checking of None assignment to nullable fields. (#​2089)
  • Fix set global fallback default in Sanic register_tortoise. (#​2090)
  • Escape [ ] for db url parsing. (#​2081) (#​2092)
  • Fix UnicodeEncodeError by using UTF-8 encoding for migration files. (#​2096, #​2097)

v1.0.0

Compare Source

.. warning::

This is a **major release** with breaking changes.
Please read the :ref:`migration_guide` before upgrading.

Breaking Changes
^^^^^^^^^^^^^^^^

  • Minimum Python version raised to 3.10 (was 3.9). (#​2062)
  • 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. (#​2023)
  • 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. (#​2061)
  • 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. (#​2084)
  • PostgreSQL full-text search: TSVectorField, SearchVector, SearchQuery, SearchRank, SearchHeadline expressions, and GIN/GiST index support. (#​2065)
  • Query API (tortoise.query_api) for building and executing custom pypika queries against models, with Model.get_table() classmethod. (#​2064)
  • TortoiseContext — explicit context manager for ORM state with full isolation. (#​2069)
  • tortoise_test_context() — modern pytest fixture helper for test isolation. (#​2069)
  • 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. (#​2027)
  • DateField now supports __year / __month / __day filters. (#​2067)

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. (#​2078)
  • Pydantic model creator internals cleaned up: removed legacy validator, improved computed field handling. (#​2079)

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. (#​631)
  • Annotations incorrectly selected in ValuesListQuery when not specified in .values_list() fields. (#​2059)
  • M2M filtering broken when two relations point to the same target model. (#​2083)
  • Pydantic incorrectly marking fields with default values as Optional. (#​2082)
  • Model.in_bulk type annotation now supports any primary key type. (#​2075)
  • Migration bug fixes: field serialization, operation ordering, and sqlmigrate command added. (#​2076)

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate Bot changed the title ⬆️ Upgrade dependency tortoise-orm to v1 fix(deps): upgrade dependency tortoise-orm to v1 May 25, 2026
@renovate
renovate Bot force-pushed the renovate/tortoise-orm-1.x branch from ed50257 to 8f7a133 Compare June 13, 2026 00:04
@renovate
renovate Bot force-pushed the renovate/tortoise-orm-1.x branch from 8f7a133 to 2980712 Compare July 25, 2026 12:10
@renovate
renovate Bot force-pushed the renovate/tortoise-orm-1.x branch from 2980712 to e898edb Compare August 15, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants