]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Allow custom sorting of column in the ORM.
authorFederico Caselli <cfederico87@gmail.com>
Thu, 16 Feb 2023 20:52:18 +0000 (21:52 +0100)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 17 Feb 2023 00:21:43 +0000 (19:21 -0500)
commit361beb0bc8392c92403ffc1999eb2a9847e945c7
tree3dae6d59043f033220eff0cf2d0526fe4984bc0e
parentfa1026cd7c24d4b6e1bc2dba6e0f3d83fb8cf064
Allow custom sorting of column in the ORM.

To accommodate a change in column ordering used by ORM Declarative in
SQLAlchemy 2.0, a new parameter :paramref:`_orm.mapped_column.sort_order`
has been added that can be used to control the order of the columns defined
in the table by the ORM, for common use cases such as mixins with primary
key columns that should appear first in tables. The change notes at
:ref:`change_9297` illustrate the default change in ordering behavior
(which is part of all SQLAlchemy 2.0 releases) as well as use of the
:paramref:`_orm.mapped_column.sort_order` to control column ordering when
using mixins and multiple classes (new in 2.0.4).

Fixes: #9297
Change-Id: Ic7163d64efdc0eccb53d6ae0dd89ec83427fb675
doc/build/changelog/unreleased_20/9297.rst [new file with mode: 0644]
doc/build/changelog/whatsnew_20.rst
lib/sqlalchemy/orm/_orm_constructors.py
lib/sqlalchemy/orm/decl_base.py
lib/sqlalchemy/orm/descriptor_props.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/sql/_typing.py
lib/sqlalchemy/sql/schema.py
test/orm/declarative/test_basic.py
test/sql/test_metadata.py