Ormar

Latest version: v0.20.0

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

Scan your dependencies

Page 7 of 14

0.9.7

Not secure
Features
* Add `isnull` operator to filter and exclude methods.
python
album__name__isnull=True (sql: album.name is null)
album__name__isnull=False (sql: album.name is not null))

* Add `ormar.or_` and `ormar.and_` functions that can be used to compose
complex queries with nested conditions.
Sample query:
python
books = (
await Book.objects.select_related("author")
.filter(
ormar.and_(
ormar.or_(year__gt=1960, year__lt=1940),
author__name="J.R.R. Tolkien",
)
)
.all()
)

Check the updated docs in Queries -> Filtering and sorting -> Complex filters

Other
* Setting default on `ForeignKey` or `ManyToMany` raises and `ModelDefinition` exception as it is (and was) not supported

0.9.6

Not secure
Important
* `Through` model for `ManyToMany` relations now **becomes optional**. It's not a breaking change
since if you provide it everything works just fine as it used to. So if you don't want or need any additional
fields on `Through` model you can skip it. Note that it's going to be created for you automatically and
still has to be included in example in `alembic` migrations.
If you want to delete existing one check the default naming convention to adjust your existing database structure.

Note that you still need to provide it if you want to
customize the `Through` model name or the database table name.

Features
* Add `update` method to `QuerysetProxy` so now it's possible to update related models directly from parent model
in `ManyToMany` relations and in reverse `ForeignKey` relations. Note that update like in `QuerySet` `update` returns number of
updated models and **does not update related models in place** on parent model. To get the refreshed data on parent model you need to refresh
the related models (i.e. `await model_instance.related.all()`)
* Add `load_all(follow=False, exclude=None)` model method that allows to load current instance of the model
with all related models in one call. By default it loads only directly related models but setting
`follow=True` causes traversing the tree (avoiding loops). You can also pass `exclude` parameter
that works the same as `QuerySet.exclude_fields()` method.
* Added possibility to add more fields on `Through` model for `ManyToMany` relationships:
* name of the through model field is the lowercase name of the Through class
* you can pass additional fields when calling `add(child, **kwargs)` on relation (on `QuerysetProxy`)
* you can pass additional fields when calling `create(**kwargs)` on relation (on `QuerysetProxy`)
when one of the keyword arguments should be the through model name with a dict of values
* you can order by on through model fields
* you can filter on through model fields
* you can include and exclude fields on through models
* through models are attached only to related models (i.e. if you query from A to B -> only on B)
* note that through models are explicitly loaded without relations -> relation is already populated in ManyToMany field.
* note that just like before you cannot declare the relation fields on through model, they will be populated for you by `ormar`,
but now if you try to do so `ModelDefinitionError` will be thrown
* check the updated ManyToMany relation docs for more information

Other
* Updated docs and api docs
* Refactors and optimisations mainly related to filters, exclusions and order bys

0.9.5

Not secure
Fixes
* Fix creation of `pydantic` FieldInfo after update of `pydantic` to version >=1.8
* Pin required dependency versions to avoid such situations in the future

0.9.4

Not secure
Fixes
* Fix `fastapi` OpenAPI schema generation for automatic docs when multiple models refer to the same related one

0.9.3

Not secure
Fixes
* Fix `JSON` field being double escaped when setting value after initialization
* Fix `JSON` field not respecting `nullable` field setting due to `pydantic` internals
* Fix `choices` verification for `JSON` field
* Fix `choices` not being verified when setting the attribute after initialization
* Fix `choices` not being verified during `update` call from `QuerySet`

0.9.2

Not secure
Other

* Updated the Quick Start in docs/readme
* Updated docs with links to queries subpage
* Added badges for code climate and pepy downloads

Page 7 of 14

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.