Tortoise-orm

Latest version: v0.20.1

Safety actively analyzes 628924 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 8 of 23

0.16.0

Not secure
------
.. caution::
**This release drops support for Python 3.6:**

Tortoise ORM now requires a minimum of CPython 3.7

New features:
^^^^^^^^^^^^^
* Model docstrings and ``:`` comments directly preceding Field definitions are now used as docstrings and DDL descriptions.

This is now cleaned and carried as part of the ``docstring`` parameter in ``describe_model(...)``

If one doesn't explicitly specify a Field ``description=`` or Model ``Meta.table_description=`` then we default to the first line as the description.
This is done because a description is submitted to the DB, and needs to be short (depending on DB, 63 chars) in size.

Usage example:

.. code-block:: python3

class Something(Model):
"""
A Docstring.

Some extra info.
"""

A regular comment
name = fields.CharField(max_length=50)
: A docstring comment
chars = fields.CharField(max_length=50, description="Some chars")
: A docstring comment
: Some more detail
blip = fields.CharField(max_length=50)

When looking at the describe model:
{
"description": "A Docstring.",
"docstring": "A Docstring.\n\nSome extra info.",
...
"data_fields": [
{
"name": "name",
...
"description": null,
"docstring": null
},
{
"name": "chars",
...
"description": "Some chars",
"docstring": "A docstring comment"
},
{
"name": "blip",
...
"description": "A docstring comment",
"docstring": "A docstring comment\nSome more detail"
}
]
}

* Early Partial Init of models.

We now have an early init of models, which can be useful when needing Models that are not bound to a DB, but otherwise complete.
e.g. Schema generation without needing to be properly set up.

Usage example:

.. code-block:: python3

Lets say you defined your models in "some/models.py", and "other/ddef.py"
And you are going to use them in the "model" namespace:
Tortoise.init_models(["some.models", "other.ddef"], "models")

Now the models will have relationships built, so introspection of schema will be comprehensive

* Pydantic serialisation.

We now include native support for automatically building a Pydantic model from Tortoise ORM models.
This will correctly model:

* Data Fields
* Relationships (FK/O2O/M2M)
* Callables

At this stage we only support serialisation, not deserialisation.

For mode information, please see :ref:`contrib_pydantic`

- Allow usage of ``F`` expressions to in annotations. (301)
- Now negative number with ``limit(...)`` and ``offset(...)`` raise ``ParamsError``. (306)
- Allow usage of Function to ``queryset.update()``. (308)
- Add ability to supply ``distinct`` flag to Aggregate (312)


Bugfixes:
^^^^^^^^^
- Fix default type of ``JSONField``

Removals:
^^^^^^^^^
- Removed ``tortoise.aggregation`` as this was deprecated since 0.14.0
- Removed ``start_transaction`` as it has been broken since 0.15.0
- Removed support for Python 3.6 / PyPy-3.6, as it has been broken since 0.15.0

If you still need Python 3.6 support, you can install ``tortoise-orm<0.16`` as we will still backport critical bugfixes to the 0.15 branch for a while.

.. rst-class:: emphasize-children

0.15.24

-------
- Fixed regression where ``GROUP BY`` class is missing for an aggregate with a specified order.

0.15.23

-------
- Fixed SQL injection issue in MySQL
- Fixed SQL injection issues in MySQL when using ``contains``, ``starts_with`` or ``ends_with`` filters (and their case-insensitive counterparts)
- Fixed malformed SQL for PostgreSQL and SQLite when using ``contains``, ``starts_with`` or ``ends_with`` filters (and their case-insensitive counterparts)

0.15.22

Not secure
-------
* Fix the aggregates using the wrong side of the join when doing a self-referential aggregation.
* Fix for ``generate_schemas`` param being ignored in ``tortoise.contrib.quart.register_tortoise``

0.15.21

Not secure
-------
* Fixed invalid ``var IN ()`` SQL generated using ``__in=`` and ``__not_in`` filters.
* Fix bug with order_by on nested fields
* Fix joining with self by reverse-foreign-key for filtering and annotation

0.15.20

Not secure
-------
* Default ``values()`` & ``values_list()`` now includes annotations.
* Annotations over joins now work correctly with ``values()`` & ``values_list()``
* Ensure ``GROUP BY`` precedes ``HAVING`` to ensure that filtering by aggregates work correctly.
* Cast ``BooleanField`` values correctly on SQLite & MySQL

Page 8 of 23

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.