summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/assertsql.py
diff options
context:
space:
mode:
authorNicolas CANIART <nicolas@caniart.net>2019-08-22 14:16:29 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-08-27 12:59:21 -0400
commit75b2518b2659796c885396fd0893dd7f9b19a9ef (patch)
treea7d67e8d62ab16306ae2881dfd1c944a69fd3eed /lib/sqlalchemy/testing/assertsql.py
parent94385b031c1dac004ee4181cb5783328d740d110 (diff)
downloadsqlalchemy-75b2518b2659796c885396fd0893dd7f9b19a9ef.tar.gz
Implement type-level sorting for Enum; apply to ORM primary keys
Added support for the use of an :class:`.Enum` datatype using Python pep-435 enumeration objects as values for use as a primary key column mapped by the ORM. As these values are not inherently sortable, as required by the ORM for primary keys, a new :attr:`.TypeEngine.sort_key_function` attribute is added to the typing system which allows any SQL type to implement a sorting for Python objects of its type which is consulted by the unit of work. The :class:`.Enum` type then defines this using the database value of a given enumeration. The sorting scheme can be also be redefined by passing a callable to the :paramref:`.Enum.sort_key_function` parameter. Pull request courtesy Nicolas Caniart. Fixes: #4285 Closes: #4816 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4816 Pull-request-sha: 42266b766c1e462d5b8a409cda05d33dea13bd34 Change-Id: Iadcc16173c1ba26ffac5830db57743a4cb987c55
Diffstat (limited to 'lib/sqlalchemy/testing/assertsql.py')
0 files changed, 0 insertions, 0 deletions