Releases: collerek/ormar
Releases · collerek/ormar
Fix pydantic update
0.9.5
Fixes
- Fix creation of
pydantic
FieldInfo after update ofpydantic
to version >=1.8 - Pin required dependency versions to avoid such situations in the future
Fix `fastapi` OpenAPI schema generation for automatic docs when multiple models refer to the same related one
0.9.4
Fixes
- Fix
fastapi
OpenAPI schema generation for automatic docs when multiple models refer to the same related one
Fix Json fields and choices validation
Fixes
- Fix
JSON
field being double escaped when setting value after initialization - Fix
JSON
field not respectingnullable
field setting due topydantic
internals - Fix
choices
verification forJSON
field - Fix
choices
not being verified when setting the attribute after initialization - Fix
choices
not being verified duringupdate
call fromQuerySet
Update docs and quick start so publish on pypi
Other
- Updated the Quick Start in docs/readme
- Updated docs with links to queries subpage
- Added badges for code climate and pepy downloads
Add choices params as Enum details
0.9.1
Features
- Add choices values to
OpenAPI
specs, so it looks like nativeEnum
field in the result schema.
Fixes
- Fix
choices
behavior withfastapi
usage when special fields can be not initialized yet but passed as strings etc.
Fix for foreign keys missing in generated ddl for all backends
0.9.0
Important
- Braking Fix: Version 0.8.0 introduced a bug that prevents generation of foreign_keys constraint in the database,
both in alembic and during creation through sqlalchemy.engine, this is fixed now. - THEREFORE IF YOU USE VERSION >=0.8.0 YOU ARE STRONGLY ADVISED TO UPDATE cause despite
that most of theormar
functions are working your database CREATED with ormar (or ormar + alembic)
does not have relations and suffer from perspective of performance and data integrity. - If you were using
ormar
to connect to existing database your performance and integrity
should be fine nevertheless you should update to reflect all future schema updates in your models.
Breaking
- Breaking: All foreign_keys and unique constraints now have a name so
alembic
can identify them in db and not depend on db - Breaking: During model construction if
Meta
class of theModel
does not
includemetadata
ordatabase
nowModelDefinitionError
will be raised instead of genericAttributeError
. - Breaking:
encode/databases
used for running the queries does not have a connection pool
for sqlite backend, meaning that each querry is run with a new connection and there is no way to
enable enforcing ForeignKeys constraints as those are by default turned off on every connection.
This is changed inormar
since >=0.9.0 and by default each sqlite3 query has"PRAGMA foreign_keys=1;"
run so now each sqlite3 connection by default enforces ForeignKey constraints including cascades.
Other
- Update api docs.
- Add tests for fk creation in db and for cascades in db
Allow for processing of ForwardRefs
Features
- Introduce processing of
ForwardRef
in relations.
Now you can create self-referencing models - bothForeignKey
andManyToMany
relations.
ForwardRef
can be used both forto
andthrough
Models
. - Introduce the possibility to perform two same relation joins in one query, so to process complex relations like:
B = X = Y // A \ C = X = Y <= before you could link from X to Y only once in one query unless two different relation were used (two relation fields with different names)
- Introduce the
paginate
method that allows to limit/offset bypage
andpage_size
.
Available forQuerySet
andQuerysetProxy
.
Other
- Refactoring and performance optimization in queries and joins.
- Add python 3.9 to tests and pypi setup.
- Update API docs and docs -> i.e. split of queries documentation.
Introduce inheritance
Breaking
- Breaking:
remove()
parent from child side in reverse ForeignKey relation now requires passing a relationname
,
as the same model can be registered multiple times andormar
needs to know from which relation on the parent you want to remove the child. - Breaking: applying
limit
andoffset
withselect_related
is by default applied only on the main table before the join -> meaning that not the total
number of rows is limited but just number of main models (first one in the query, the one used to construct it). You can still limit all rows from db response withlimit_raw_sql=True
flag on eitherlimit
oroffset
(or both) - Breaking: issuing
first()
now fetches the first row ordered by the primary key asc (so first one inserted (can be different for non number primary keys - i.e. alphabetical order of string)) - Breaking: issuing
get()
without any filters now fetches the first row ordered by the primary key desc (so should be last one inserted (can be different for non number primary keys - i.e. alphabetical order of string)) - Breaking (internal): sqlalchemy columns kept at
Meta.columns
are no longer bind to table, so you cannot get the column straight from there
Features
- Introduce inheritance. For now two types of inheritance are possible:
- Mixins - don't subclass
ormar.Model
, just define fields that are later used on different models (likecreated_date
andupdated_date
on each child model), only actual models create tables, but those fields from mixins are added - Concrete table inheritance - means that parent is marked as
abstract=True
in Meta class and each child has its own table with columns from the parent and own child columns, kind of similar to Mixins but parent also is a (an abstract) Model - To read more check the docs on models -> inheritance section.
- Mixins - don't subclass
- QuerySet
first()
can be used withprefetch_related
Fixes
- Fix minor bug in
order_by
for primary model order bys - Fix in
prefetch_query
for multiple related_names for the same model. - Fix using same
related_name
on different models leading to the same relatedModel
overwriting each other, nowModelDefinitionError
is raised and you need to change the name. - Fix
order_by
overwriting conditions when multiple joins to the same table applied.
Docs
- Split and cleanup in docs:
- Divide models section into subsections
- Divide relations section into subsections
- Divide fields section into subsections
- Add model inheritance section
- Add API (BETA) documentation
Fix relation names with multiple connections to one model
Fix issue #73
Add possibility to define multiple relations to same model,, fix many to many joins and relations
Add possibility to define multiple relations to same model,, fix many to many joins and relations
Pre-release
Pre-release
- Allow multiple relations to the same related model/table.
- Fix for wrong relation column used in many_to_many relation joins (fix #73)
- Fix for wrong relation population for m2m relations when also fk relation present for same model.
- Add check if user provide related_name if there are multiple relations to same table on one model.
- More eager cleaning of the dead weak proxy models.