In this release we have added the sort_by method of the Query object. At this point it is an alias of the order_by method. In the release 0.8 we are going to make a backward incompatible change and slightly modify the behavior of the order_by method. If you replace the order_by with sort_by it will continue working without any problems in this and future releases. There is no urgency to make this change – it is a preparation for the 0.8 release.
Here is the list of changes in this release:
New features
where()method added to the Query objectcoalesce()function addedbetween(x, a, b)function added- #295: Add
_table_options_for entity class to specify engine, tablespace, etc. - Make debug flag thread-local
sql_debuggingcontext manager addedsql_debugandshow_valuesarguments were added todb_sessionset_sql_debugfunction added as alias to (to be deprecated)sql_debugfunction- Allow
db_sessionto acceptddlparameter when used as context manager - Add
optimistic=Trueoption to db_session - Skip optimistic checks for queries in
db_sessionwithserializable=True fk_nameoption added for attributes in order to specify foreign key name- #280: Now it’s possible to specify
timeoutoption indb.bind()method for SQLite, as well as pass other keyword arguments forsqlite3.connectfunction - Add support of explicit casting to int in queries using
int()function - Added modulo division % native support in queries
Bugfixes
- Fix bugs with composite table names
- Fix invalid foreign key & index names for tables which names include schema name
- For queries like
select(x for x in MyObject if not x.description)add “OR x.info IS NULL” for nullable string columns - Add optimistic checking for
delete()method - Show updated attributes when
OptimisticCheckErroris being raised - Fix incorrect aliases in nested queries
- Correctly pass exception from user-defined functions in SQLite
- More clear error messages for
UnrepeatableReadError - Fix
db_session(strict=True)which was broken in 2d3afb24 - Fixes #170: Problem with a primary key column used as a part of another key
- Fixes #223: incorrect result of
getattr(entity, attrname)when the same lambda applies to different entities - Fixes #266: Add handler to
"pony.orm"logger does not work - Fixes #278: Cascade delete error: FOREIGN KEY constraint failed, with complex entity relationships
- Fixes #283: Lost Json update immediately after object creation
- Fixes #284:
query.order_by()orders Json numbers like strings - Fixes #288: Expression text parsing issue in Python 3
- Fixes #293: translation of if-expressions in expression
- Fixes #294: Real stack traces swallowed within IPython shell
Collection.count()method now checks if session is alive- Set
obj._session_cache_to None after exiting from db session for better garbage collection - Unload collections which are not fully loaded after exiting from db session for better garbage collection
- Raise on unknown options for attributes that are part of relationship