3.9.0
New and improved stuff
- Added new document describing how to use peewee interactively.
- Added convenience functions for generating model classes from a pre-existing database, printing model definitions and printing CREATE TABLE sql for a model. See the "use peewee interactively" section for details.
- Added a
__str__
implementation to allQuery
subclasses which converts the query to a string and interpolates the parameters. - Improvements to
sqlite_ext.JSONField
regarding the serialization of data, as well as the addition of options to override the JSON serialization and de-serialization functions. - Added
index_type
parameter toField
- Added
DatabaseProxy
, which allows one to use database-specific decorators with an uninitializedProxy
object. See #1842 for discussion. Recommend that you update any usage ofProxy
for deferring database initialization to use the newDatabaseProxy
class instead. - Added support for
INSERT ... ON CONFLICT
when the conflict target is a partial index (e.g., contains aWHERE
clause). TheOnConflict
andon_conflict()
APIs now take an additionalconflict_where
parameter to represent theWHERE
clause of the partial index in question. See #1860. - Enhanced the
playhouse.kv
extension to use efficient upsert for all database engines. Previously upsert was only supported for sqlite and mysql. - Re-added the
orwhere()
query filtering method, which will append the given expressions usingOR
instead ofAND
. See #391 for old discussion. - Added some new examples to the
examples/
directory - Added
select_from()
API for wrapping a query and selecting one or more columns from the wrapped subquery. Docs. - Added documentation on using row values.
- Removed the (defunct) "speedups" C extension, which as of 3.8.2 only contained a barely-faster function for quoting entities.
Bugfixes
- Fix bug in SQL generation when there was a subquery that used a common table expressions.
- Enhanced
prefetch()
and fixed bug that could occur when mixing self-referential foreign-keys and model aliases. - MariaDB 10.3.3 introduces backwards-incompatible changes to the SQL used for upsert. Peewee now introspects the MySQL server version at connection time to ensure proper handling of version-specific features. See #1834 for details.
- Fixed bug where
TimestampField
would treat zero values asNone
when reading from the database.