Peewee Versions Save

a small, expressive orm -- supports postgresql, mysql, sqlite and cockroachdb

3.15.2

1 year ago
  • Fix bug where field-specific conversions were being applied to the pattern used for LIKE / ILIKE operations. Refs #2609
  • Fix possible infinite loop when accidentally invoking the __iter__ method on certain Column subclasses. Refs #2606
  • Add new helper for specifying which Model a particular selected column-like should be bound to, in queries with joins that select from multiple sources.

View commits

3.15.1

1 year ago
  • Fix issue introduced in Sqlite 3.39.0 regarding the propagation of column subtypes in subqueries. Affected sqlite changelog extension when used with JSON columns.
  • Fix bug where cockroachdb server version was not set when beginning a transaction on an unopened database.

View commits

3.15.0

1 year ago

Rollback 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:

  • Add shortcuts.insert_where() helper for generating conditional INSERT with a bit less boilerplate.
  • Fix bug in test_utils.count_queres() which could erroneously include pool events such as connect/disconnect, etc.

View commits

3.14.10

2 years ago
  • Add shortcut for conditional insert using sub-select, see #2528
  • Add convenience left_outer_join() method to query.
  • Add selected_columns property to Select queries.
  • Add name property to Alias instances.
  • Fix regression in tests introduced by change to DataSet in 3.14.9.

View commits

3.14.9

2 years ago
  • Allow calling table_exists() with a model-class, refs
  • Improve is_connection_usable() method of MySQLDatabase class.
  • Better support for VIEWs with playhouse.dataset.DataSet and sqlite-web.
  • Support INSERT / ON CONFLICT in playhosue.kv for newer Sqlite.
  • Add ArrayField.contained_by() method, a corollary to contains() and the contains_any() methods.
  • Support cyclical foreign-key relationships in reflection/introspection, and also for sqlite-web.
  • Add magic methods for FTS5 field to optimize, rebuild and integrity check the full-text index.
  • Add fallbacks in setup.py in the event distutils is not available.

View commits

3.14.8

2 years ago

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.

View commits

3.14.7

2 years ago

Fix bug in APSW extension with Sqlite 3.35 and newer, due to handling of last insert rowid with RETURNING. Refs #2479.

View commits

3.14.6

2 years ago

Fix pesky bug in new last_insert_id() on the SqliteExtDatabase.

View commits

3.14.5

2 years ago

Note: this release contained a bug and has been removed from PyPI. Use 3.14.6 or newer.

This release contains a number of bug-fixes and small improvements.

  • Only raise DoesNotExist when lazy_load is enabled on ForeignKeyField, fixes issue #2377.
  • Add missing convenience method ModelSelect.get_or_none()
  • Allow ForeignKeyField to specify a custom BackrefAccessorClass, references issue #2391.
  • Ensure foreign-key-specific conversions are applied on INSERT and UPDATE, fixes #2408.
  • Add handling of MySQL error 4031 (inactivity timeout) to the ReconnectMixin helper class. Fixes #2419.
  • Support specification of conflict target for ON CONFLICT/DO NOTHING.
  • Add encoding parameter to the DataSet freeze() and thaw() methods, fixes #2425.
  • Fix bug which prevented DeferredForeignKey from being used as a model's primary key, fixes #2427.
  • Ensure foreign key's related object cache is cleared when the foreign-key is set to None. Fixes #2428.
  • Allow specification of (schema, table) to be used with CREATE TABLE AS..., fixes #2423.
  • Allow reusing open connections with DataSet, refs #2441.
  • Add highlight() and snippet() helpers to Sqlite SearchField, for use with full-text search extension.
  • Preserve user-provided aliases in column names. Fixes #2453.
  • Add support for Sqlite 3.37 strict tables.
  • Ensure database is inherited when using ThreadSafeDatabaseMetadata, and also adds an implementation in playhouse.shortcuts along with basic unit tests.
  • Better handling of Model's dirty fields when saving, fixes #2466.
  • Add basic support for MariaDB connector driver in playhouse.mysql_ext, refs issue #2471.
  • Begin a basic implementation for a psycopg3-compatible pg database, refs issue #2473.
  • Add provisional support for RETURNING when using the appropriate versions of Sqlite or MariaDB.

View commits

3.14.4

3 years ago

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.

View commits