a small, expressive orm -- supports postgresql, mysql, sqlite and cockroachdb
__iter__
method on certain Column
subclasses. Refs #2606Rollback behavior change in commit ab43376697 (GH #2026). Peewee will no longer
automatically return the cursor rowcount
for certain bulk-inserts. This
should only affect users of MySQL and Sqlite who relied on a bulk INSERT
returning the rowcount
(as opposed to the cursor's lastrowid
). The
rowcount
behavior is still available chaining the as_rowcount()
method:
# NOTE: this change only affects MySQL or Sqlite.
db = MySQLDatabase(...)
# Previously, bulk inserts of the following forms would return the rowcount.
query = User.insert_many(...) # Bulk insert.
query = User.insert_from(...) # Bulk insert (INSERT INTO .. SELECT FROM).
# Previous behavior (peewee 3.12 - 3.14.10):
# rows_inserted = query.execute()
# New behavior:
last_id = query.execute()
# To get the old behavior back:
rows_inserted = query.as_rowcount().execute()
This release contains a fix for a long-standing request to allow data-modifying queries to support CTEs. CTEs are now supported for use with INSERT, DELETE and UPDATE queries - see #2152.
Additionally, this release adds better support for using the new RETURNING
syntax with Sqlite automatically. Specify returning_clause=True
when
initializing your SqliteDatabase
and all bulk inserts will automatically
specify a RETURNING
clause, returning the newly-inserted primary keys. This
functionality requires Sqlite 3.35 or newer.
Smaller changes:
shortcuts.insert_where()
helper for generating conditional INSERT with a bit less boilerplate.test_utils.count_queres()
which could erroneously include pool events such as connect/disconnect, etc.left_outer_join()
method to query.selected_columns
property to Select queries.name
property to Alias instances.table_exists()
with a model-class, refsis_connection_usable()
method of MySQLDatabase
class.playhouse.dataset.DataSet
and sqlite-web.playhosue.kv
for newer Sqlite.ArrayField.contained_by()
method, a corollary to contains()
and the contains_any()
methods.setup.py
in the event distutils is not available.Back-out all changes to automatically use RETURNING for SqliteExtDatabase
, CSqliteExtDatabase
and APSWDatabase
. The issue I found is that when a RETURNING cursor is not fully-consumed, any parent SAVEPOINT (and possibly transaction) would not be able to be released. Since this is a backwards-incompatible change, I am going to back it out for now.
Returning clause can still be specified for Sqlite, however it just needs to be done so manually rather than having it applied automatically.
Fix bug in APSW extension with Sqlite 3.35 and newer, due to handling of last insert rowid with RETURNING. Refs #2479.
Fix pesky bug in new last_insert_id()
on the SqliteExtDatabase
.
This release contains a number of bug-fixes and small improvements.
DoesNotExist
when lazy_load
is enabled on ForeignKeyField, fixes issue #2377.ModelSelect.get_or_none()
ForeignKeyField
to specify a custom BackrefAccessorClass
, references issue #2391.ReconnectMixin
helper class. Fixes #2419.encoding
parameter to the DataSet freeze()
and thaw()
methods, fixes #2425.DeferredForeignKey
from being used as a model's primary key, fixes #2427.None
. Fixes #2428.(schema, table)
to be used with CREATE TABLE AS..., fixes #2423.highlight()
and snippet()
helpers to Sqlite SearchField
, for use with full-text search extension.ThreadSafeDatabaseMetadata
, and also adds an implementation in playhouse.shortcuts
along with basic unit tests.playhouse.mysql_ext
, refs issue #2471.This release contains an important fix for a regression introduced by commit ebe3ad5, which affected the way model instances are converted to parameters for use in expressions within a query. The bug could manifest when code uses model instances as parameters in expressions against fields that are not foreign-keys.
The issue is described in #2376.