Skip to content

Releases: collerek/ormar

Fix pydantic update

28 Feb 08:26
Compare
Choose a tag to compare

0.9.5

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

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

17 Feb 17:28
88baf9e
Compare
Choose a tag to compare

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

11 Feb 10:44
56d8c11
Compare
Choose a tag to compare

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

Update docs and quick start so publish on pypi

06 Feb 13:24
Compare
Choose a tag to compare

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

03 Feb 14:04
16cd068
Compare
Choose a tag to compare

0.9.1

Features

  • Add choices values to OpenAPI specs, so it looks like native Enum field in the result schema.

Fixes

  • Fix choices behavior with fastapi 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

02 Feb 11:54
a6166ed
Compare
Choose a tag to compare

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 the ormar 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 the Model does not
    include metadata or database now ModelDefinitionError will be raised instead of generic AttributeError.
  • 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 in ormar 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

29 Jan 13:50
64b0004
Compare
Choose a tag to compare

Features

  • Introduce processing of ForwardRef in relations.
    Now you can create self-referencing models - both ForeignKey and ManyToMany relations.
    ForwardRef can be used both for to and through 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 by page and page_size.
    Available for QuerySet and QuerysetProxy.

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

06 Jan 16:06
e641365
Compare
Choose a tag to compare
Introduce inheritance Pre-release
Pre-release

Breaking

  • Breaking: remove() parent from child side in reverse ForeignKey relation now requires passing a relation name,
    as the same model can be registered multiple times and ormar needs to know from which relation on the parent you want to remove the child.
  • Breaking: applying limit and offset with select_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 with limit_raw_sql=True flag on either limit or offset (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 (like created_date and updated_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.
  • QuerySet first() can be used with prefetch_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 related Model overwriting each other, now ModelDefinitionError 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

15 Dec 13:37
a2c6bdb
Compare
Choose a tag to compare

Add possibility to define multiple relations to same model,, fix many to many joins and relations

14 Dec 18:12
Compare
Choose a tag to compare
  • 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.