coleifer/peewee
### [`v3.16.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3162)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.16.1...3.16.2)
Fixes a longstanding issue with thread-safety of various decorators, including
`atomic()`, `transaction()`, `savepoint()`. The context-managers are
unaffected. See [#2709](https://togithub.com/coleifer/peewee/issues/2709) for details.
[View commits](https://togithub.com/coleifer/peewee/compare/3.16.1...3.16.2)
### [`v3.16.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3161)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.16.0...3.16.1)
- Add changes required for building against Cython 3.0 and set Cython
language-level to 3.
- Ensure indexes aren't added to unindexed fields during introspection, [#2691](https://togithub.com/coleifer/peewee/issues/2691).
- Ensure we don't redundantly select same PK in prefetch when using
PREFETCH_TYPE.JOIN.
- In Sqlite migrator, use Sqlite's builtin DROP and RENAME column facilities
when possible. This can be overridden by passing `legacy=True` flag.
[View commits](https://togithub.com/coleifer/peewee/compare/3.16.0...3.16.1)
### [`v3.16.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3160)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.4...3.16.0)
This release contains backwards-incompatible changes in the way Peewee
initializes connections to the underlying database driver. Previously, peewee
implemented autocommit semantics *on-top* of the existing DB-API transactional
workflow. Going forward, Peewee instead places the DB-API driver into
autocommit mode directly.
Why this change?
Previously, Peewee emulated autocommit behavior for top-level queries issued
outside of a transaction. This necessitated a number of checks which had to be
performed each time a query was executed, so as to ensure that we didn't end up
with uncommitted writes or, conversely, idle read transactions. By running the
underlying driver in autocommit mode, we can eliminate all these checks, since
we are already managing transactions ourselves.
Behaviorally, there should be no change -- Peewee will still treat top-level
queries outside of transactions as being autocommitted, while queries inside of
`atomic()` / `with db:` blocks are implicitly committed at the end of the
block, or rolled-back if an exception occurs.
**How might this affect me?**
- If you are using the underlying database connection or cursors, e.g. via
`Database.connection()` or `Database.cursor()`, your queries will now be
executed in autocommit mode.
- The `commit=` argument is deprecated for the `cursor()`, `execute()` and
`execute_sql()` methods.
- If you have a custom `Database` implementation (whether for a database that
is not officially supported, or for the purpose of overriding default
behaviors), you will want to ensure that your connections are opened in
autocommit mode.
Other changes:
- Some fixes to help with packaging in Python 3.11.
- MySQL `get_columns()` implementation now returns columns in their declared
order.
[View commits](https://togithub.com/coleifer/peewee/compare/3.15.4...3.16.0)
### [`v3.15.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3154)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.3...3.15.4)
- Raise an exception in `ReconnectMixin` if connection is lost while inside a
transaction (if the transaction was interrupted presumably some changes were
lost and explicit intervention is needed).
- Add `db.Model` property to reduce boilerplate.
- Add support for running `prefetch()` queries with joins instead of subqueries
(this helps overcome a MySQL limitation about applying LIMITs to a subquery).
- Add SQL `AVG` to whitelist to avoid coercing by default.
- Allow arbitrary keywords in metaclass constructor, [#2627](https://togithub.com/coleifer/peewee/issues/2627)
- Add a `pyproject.toml` to silence warnings from newer pips when `wheel`
package is not available.
This release has a small helper for reducing boilerplate in some cases by
exposing a base model class as an attribute of the database instance.
```python
```
### [`v3.15.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3153)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.2...3.15.3)
- Add `scalars()` query method (complements `scalar()`), roughly equivalent to
writing `[t[0] for t in query.tuples()]`.
- Small doc improvements
- Fix and remove some flaky test assertions with Sqlite INSERT + RETURNING.
- Fix innocuous failing Sqlite test on big-endian machines.
[View commits](https://togithub.com/coleifer/peewee/compare/3.15.2...3.15.3)
### [`v3.15.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3152)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.1...3.15.2)
- Fix bug where field-specific conversions were being applied to the pattern
used for LIKE / ILIKE operations. Refs [#2609](https://togithub.com/coleifer/peewee/issues/2609)
- Fix possible infinite loop when accidentally invoking the `__iter__` method
on certain `Column` subclasses. Refs [#2606](https://togithub.com/coleifer/peewee/issues/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](https://togithub.com/coleifer/peewee/compare/3.15.1...3.15.2)
### [`v3.15.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3151)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.0...3.15.1)
- Fix issue introduced in Sqlite 3.39.0 regarding the propagation of column
subtypes in subqueries.
- Fix bug where cockroachdb server version was not set when beginning a
transaction on an unopened database.
[View commits](https://togithub.com/coleifer/peewee/compare/3.15.0...3.15.1)
### [`v3.15.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3150)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.10...3.15.0)
Rollback behavior change in commit [`ab43376`](https://togithub.com/coleifer/peewee/commit/ab43376697) (GH [#2026](https://togithub.com/coleifer/peewee/issues/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:
```python
```
### [`v3.14.10`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#Previous-behavior-peewee-312---31410-)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.9...3.14.10)
### Previous behavior (peewee 3.12 - 3.14.10):
### [`v3.14.9`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3149)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.8...3.14.9)
- 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](https://togithub.com/coleifer/peewee/compare/3.14.8...3.14.9)
### [`v3.14.8`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3148)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.7...3.14.8)
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](https://togithub.com/coleifer/peewee/compare/3.14.7...3.14.8)
### [`v3.14.7`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3147)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.6...3.14.7)
Fix bug in APSW extension with Sqlite 3.35 and newer, due to handling of last
insert rowid with RETURNING. Refs [#2479](https://togithub.com/coleifer/peewee/issues/2479).
[View commits](https://togithub.com/coleifer/peewee/compare/3.14.6...3.14.7)
### [`v3.14.6`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3146)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.4...3.14.6)
Fix pesky bug in new `last_insert_id()` on the `SqliteExtDatabase`.
[View commits](https://togithub.com/coleifer/peewee/compare/3.14.5...3.14.6)
### [`v3.14.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3144)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.3...3.14.4)
This release contains an important fix for a regression introduced by commit
[`ebe3ad5`](https://togithub.com/coleifer/peewee/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](https://togithub.com/coleifer/peewee/issues/2376).
[View commits](https://togithub.com/coleifer/peewee/compare/3.14.3...3.14.4)
### [`v3.14.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3143)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.2...3.14.3)
This release contains a single fix for ensuring NULL values are inserted when
issuing a bulk-insert of heterogeneous dictionaries which may be missing
explicit NULL values. Fixes issue [#2638](https://togithub.com/coleifer/peewee/issues/2638).
[View commits](https://togithub.com/coleifer/peewee/compare/3.14.2...3.14.3)
### [`v3.14.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3142)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.1...3.14.2)
This is a small release mainly to get some fixes out.
- Support for named `Check` and foreign-key constraints.
- Better foreign-key introspection for CockroachDB (and Postgres).
- Register UUID adapter for Postgres.
- Add `fn.array_agg()` to blacklist for automatic value coercion.
[View commits](https://togithub.com/coleifer/peewee/compare/3.14.1...3.14.2)
### [`v3.14.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#Previous-behavior-peewee-312---31410-)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.0...3.14.1)
### Previous behavior (peewee 3.12 - 3.14.10):
### [`v3.14.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3140)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.13.3...3.14.0)
This release has been a bit overdue and there are numerous small improvements
and bug-fixes. The bugfix that prompted this release is [#2293](https://togithub.com/coleifer/peewee/issues/2293), which is a
regression in the Django-inspired `.filter()` APIs that could cause some
filter expressions to be discarded from the generated SQL. Many thanks for the
excellent bug report, Jakub.
- Add an experimental helper, `shortcuts.resolve_multimodel_query()`, for
resolving multiple models used in a compound select query.
- Add a `lateral()` method to select query for use with lateral joins, refs
issue [#2205](https://togithub.com/coleifer/peewee/issues/2205).
- Added support for nested transactions (savepoints) in cockroach-db (requires
20.1 or newer).
- Automatically escape wildcards passed to string-matching methods, refs [#2224](https://togithub.com/coleifer/peewee/issues/2224).
- Allow index-type to be specified on MySQL, refs [#2242](https://togithub.com/coleifer/peewee/issues/2242).
- Added a new API, `converter()` to be used for specifying a function to use to
convert a row-value pulled off the cursor, refs [#2248](https://togithub.com/coleifer/peewee/issues/2248).
- Add `set()` and `clear()` method to the bitfield flag descriptor, refs [#2257](https://togithub.com/coleifer/peewee/issues/2257).
- Add support for `range` types with `IN` and other expressions.
- Support CTEs bound to compound select queries, refs [#2289](https://togithub.com/coleifer/peewee/issues/2289).
##### Bug-fixes
- Fix to return related object id when accessing via the object-id descriptor,
when the related object is not populated, refs [#2162](https://togithub.com/coleifer/peewee/issues/2162).
- Fix to ensure we do not insert a NULL value for a primary key.
- Fix to conditionally set the field/column on an added column in a migration,
refs [#2171](https://togithub.com/coleifer/peewee/issues/2171).
- Apply field conversion logic to model-class values. Relocates the logic from
issue [#2131](https://togithub.com/coleifer/peewee/issues/2131) and fixes [#2185](https://togithub.com/coleifer/peewee/issues/2185).
- Clone node before modifying it to be flat in an enclosed nodelist expr, fixes
issue [#2200](https://togithub.com/coleifer/peewee/issues/2200).
- Fix an invalid item assignment in nodelist, refs [#2220](https://togithub.com/coleifer/peewee/issues/2220).
- Fix an incorrect truthiness check used with `save()` and `only=`, refs [#2269](https://togithub.com/coleifer/peewee/issues/2269).
- Fix regression in `filter()` where using both `*args` and `**kwargs` caused
the expressions passed as `args` to be discarded. See [#2293](https://togithub.com/coleifer/peewee/issues/2293).
[View commits](https://togithub.com/coleifer/peewee/compare/3.13.3...3.14.0)
### [`v3.13.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3133)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.13.2...3.13.3)
- Allow arbitrary keyword arguments to be passed to `DataSet` constructor,
which are then passed to the instrospector.
- Allow scalar subqueries to be compared using numeric operands.
- Fix `bulk_create()` when model being inserted uses FK identifiers.
- Fix `bulk_update()` so that PK values are properly coerced to the right
data-type (e.g. UUIDs to strings for Sqlite).
- Allow array indices to be used as dict keys, e.g. for the purposes of
updating a single array index value.
[View commits](https://togithub.com/coleifer/peewee/compare/3.13.2...3.13.3)
### [`v3.13.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3132)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.13.1...3.13.2)
- Allow aggregate functions to support an `ORDER BY` clause, via the addition
of an `order_by()` method to the function (`fn`) instance. Refs [#2094](https://togithub.com/coleifer/peewee/issues/2094).
- Fix `prefetch()` bug, where related "backref" instances were marked as dirty,
even though they had no changes. Fixes [#2091](https://togithub.com/coleifer/peewee/issues/2091).
- Support `LIMIT 0`. Previously a limit of 0 would be translated into
effectively an unlimited query on MySQL. References [#2084](https://togithub.com/coleifer/peewee/issues/2084).
- Support indexing into arrays using expressions with Postgres array fields.
References [#2085](https://togithub.com/coleifer/peewee/issues/2085).
- Ensure postgres introspection methods return the columns for multi-column
indexes in the correct order. Fixes [#2104](https://togithub.com/coleifer/peewee/issues/2104).
- Add support for arrays of UUIDs to postgres introspection.
- Fix introspection of columns w/capitalized table names in postgres ([#2110](https://togithub.com/coleifer/peewee/issues/2110)).
- Fix to ensure correct exception is raised in SqliteQueueDatabase when
iterating over cursor/result-set.
- Fix bug comparing subquery against a scalar value. Fixes [#2118](https://togithub.com/coleifer/peewee/issues/2118).
- Fix issue resolving composite primary-keys that include foreign-keys when
building the model-graph. Fixes [#2115](https://togithub.com/coleifer/peewee/issues/2115).
- Allow model-classes to be passed as arguments, e.g., to a table function.
Refs [#2131](https://togithub.com/coleifer/peewee/issues/2131).
- Ensure postgres `JSONField.concat()` accepts expressions as arguments.
[View commits](https://togithub.com/coleifer/peewee/compare/3.13.1...3.13.2)
### [`v3.13.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3131)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.13.0...3.13.1)
Fix a regression when specifying keyword arguments to the `atomic()` or
`transaction()` helper methods. Note: this only occurs if you were using Sqlite
and were explicitly setting the `lock_type=` parameter.
[View commits](https://togithub.com/coleifer/peewee/compare/3.13.0...3.13.1)
### [`v3.13.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3130)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.12.0...3.13.0)
##### CockroachDB support added
This will be a notable release as it adds support for
[CockroachDB](https://cockroachlabs.com/), a distributed, horizontally-scalable
SQL database.
- [CockroachDB usage overview](http://docs.peewee-orm.com/en/latest/peewee/database.html#using-crdb)
- [CockroachDB API documentation](http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#crdb)
##### Other features and fixes
- Allow `FOR UPDATE` clause to specify one or more tables (`FOR UPDATE OF...`).
- Support for Postgres `LATERAL` join.
- Properly wrap exceptions raised during explicit commit/rollback in the
appropriate peewee-specific exception class.
- Capture original exception object and expose it as `exc.orig` on the
wrapped exception.
- Properly introspect `SMALLINT` columns in Postgres schema reflection.
- More flexible handling of passing database-specific arguments to `atomic()`
and `transaction()` context-manager/decorator.
- Fix non-deterministic join ordering issue when using the `filter()` API
across several tables ([#2063](https://togithub.com/coleifer/peewee/issues/2063)).
[View commits](https://togithub.com/coleifer/peewee/compare/3.12.0...3.13.0)
### [`v3.12.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3120)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.11.2...3.12.0)
- Bulk insert (`insert_many()` and `insert_from()`) will now return the row
count instead of the last insert ID. If you are using Postgres, peewee will
continue to return a cursor that provides an iterator over the newly-inserted
primary-key values by default. This behavior is being retained by default for
compatibility. Postgres users can simply specify an empty `returning()` call
to disable the cursor and retrieve the rowcount instead.
- Migration extension now supports altering a column's data-type, via the new
`alter_column_type()` method.
- Added `Database.is_connection_usabe()` method, which attempts to look at the
status of the underlying DB-API connection to determine whether the
connection is usable.
- Common table expressions include a `materialized` parameter, which can be
used to control Postgres' optimization fencing around CTEs.
- Added `BloomFilter.from_buffer()` method for populating a bloom-filter from
the output of a previous call to the `to_buffer()` method.
- Fixed APSW extension's `commit()` and `rollback()` methods to no-op if the
database is in auto-commit mode.
- Added `generate_always=` option to the `IdentityField` (defaults to False).
[View commits](https://togithub.com/coleifer/peewee/compare/3.11.2...3.12.0)
### [`v3.11.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3112)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.11.1...3.11.2)
- Implement `hash` interface for `Alias` instances, allowing them to be used in
multi-source queries.
[View commits](https://togithub.com/coleifer/peewee/compare/3.11.1...3.11.2)
### [`v3.11.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3111)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.11.0...3.11.1)
- Fix bug in new `_pk` / `get_id()` implementation for models that explicitly
have disabled a primary-key.
[View commits](https://togithub.com/coleifer/peewee/compare/3.11.0...3.11.1)
### [`v3.11.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3110)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.10.0...3.11.0)
- Fixes [#1991](https://togithub.com/coleifer/peewee/issues/1991). This particular issue involves joining 3 models together in a
chain, where the outer two models are empty. Previously peewee would make the
middle model an empty model instance (since a link might be needed from the
source model to the outermost model). But since both were empty, it is more
correct to make the intervening model a NULL value on the foreign-key field
rather than an empty instance.
- An unrelated fix came out of the work on [#1991](https://togithub.com/coleifer/peewee/issues/1991) where hashing a model whose
primary-key happened to be a foreign-key could trigger the FK resolution
query. This patch fixes the `Model._pk` and `get_id()` interfaces so they
no longer introduce the possibility of accidentally resolving the FK.
- Allow `Field.contains()`, `startswith()` and `endswith()` to compare against
another column-like object or expression.
- Workaround for MySQL prior to 8 and MariaDB handling of union queries inside
of parenthesized expressions (like IN).
- Be more permissive in letting invalid values be stored in a field whose type
is INTEGER or REAL, since Sqlite allows this.
- `TimestampField` resolution cleanup. Now values 0 *and* 1 will resolve to a
timestamp resolution of 1 second. Values 2-6 specify the number of decimal
places (hundredths to microsecond), or alternatively the resolution can still
be provided as a power of 10, e.g. 10, 1000 (millisecond), 1e6 (microsecond).
- When self-referential foreign-keys are inherited, the foreign-key on the
subclass will also be self-referential (rather than pointing to the parent
model).
- Add TSV import/export option to the `dataset` extension.
- Add item interface to the `dataset.Table` class for doing primary-key lookup,
assignment, or deletion.
- Extend the mysql `ReconnectMixin` helper to work with mysql-connector.
- Fix mapping of double-precision float in postgres schema reflection.
Previously it mapped to single-precision, now it correctly uses a double.
- Fix issue where `PostgresqlExtDatabase` and `MySQLConnectorDatabase` did not
respect the `autoconnect` setting.
[View commits](https://togithub.com/coleifer/peewee/compare/3.10.0...3.11.0)
### [`v3.10.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3100)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.6...3.10.0)
- Add a helper to `playhouse.mysql_ext` for creating `Match` full-text search
expressions.
- Added date-part properties to `TimestampField` for accessing the year, month,
day, etc., within a SQL expression.
- Added `to_timestamp()` helper for `DateField` and `DateTimeField` that
produces an expression returning a unix timestamp.
- Add `autoconnect` parameter to `Database` classes. This parameter defaults to
`True` and is compatible with previous versions of Peewee, in which executing
a query on a closed database would open a connection automatically. To make
it easier to catch inconsistent use of the database connection, this behavior
can now be disabled by specifying `autoconnect=False`, making an explicit
call to `Database.connect()` needed before executing a query.
- Added database-agnostic interface for obtaining a random value.
- Allow `isolation_level` to be specified when initializing a Postgres db.
- Allow hybrid properties to be used on model aliases. Refs [#1969](https://togithub.com/coleifer/peewee/issues/1969).
- Support aggregates with FILTER predicates on the latest Sqlite.
##### Changes
- More aggressively slot row values into the appropriate field when building
objects from the database cursor (rather than using whatever
`cursor.description` tells us, which is buggy in older Sqlite).
- Be more permissive in what we accept in the `insert_many()` and `insert()`
methods.
- When implicitly joining a model with multiple foreign-keys, choose the
foreign-key whose name matches that of the related model. Previously, this
would have raised a `ValueError` stating that multiple FKs existed.
- Improved date truncation logic for Sqlite and MySQL to make more compatible
with Postgres' `date_trunc()` behavior. Previously, truncating a datetime to
month resolution would return `'2019-08'` for example. As of 3.10.0, the
Sqlite and MySQL `date_trunc` implementation returns a full datetime, e.g.
`'2019-08-01 00:00:00'`.
- Apply slightly different logic for casting JSON values with Postgres.
Previously, Peewee just wrapped the value in the psycopg2 `Json()` helper.
In this version, Peewee now dumps the json to a string and applies an
explicit cast to the underlying JSON data-type (e.g. json or jsonb).
##### Bug fixes
- Save hooks can now be called for models without a primary key.
- Fixed bug in the conversion of Python values to JSON when using Postgres.
- Fix for differentiating empty values from NULL values in `model_to_dict`.
- Fixed a bug referencing primary-key values that required some kind of
conversion (e.g., a UUID). See [#1979](https://togithub.com/coleifer/peewee/issues/1979) for details.
- Add small jitter to the pool connection timestamp to avoid issues when
multiple connections are checked-out at the same exact time.
[View commits](https://togithub.com/coleifer/peewee/compare/3.9.6...3.10.0)
### [`v3.9.6`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#396)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.5...3.9.6)
- Support nesting the `Database` instance as a context-manager. The outermost
block will handle opening and closing the connection along with wrapping
everything in a transaction. Nested blocks will use savepoints.
- Add new `session_start()`, `session_commit()` and `session_rollback()`
interfaces to the Database object to support using transactional controls in
situations where a context-manager or decorator is awkward.
- Fix error that would arise when attempting to do an empty bulk-insert.
- Set `isolation_level=None` in SQLite connection constructor rather than
afterwards using the setter.
- Add `create_table()` method to `Select` query to implement `CREATE TABLE AS`.
- Cleanup some declarations in the Sqlite C extension.
- Add new example showing how to implement Reddit's ranking algorithm in SQL.
[View commits](https://togithub.com/coleifer/peewee/compare/3.9.5...3.9.6)
### [`v3.9.5`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#395)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.4...3.9.5)
- Added small helper for setting timezone when using Postgres.
- Improved SQL generation for `VALUES` clause.
- Support passing resolution to `TimestampField` as a power-of-10.
- Small improvements to `INSERT` queries when the primary-key is not an
auto-incrementing integer, but is generated by the database server (eg uuid).
- Cleanups to virtual table implementation and python-to-sqlite value
conversions.
- Fixed bug related to binding previously-unbound models to a database using a
context manager, [#1913](https://togithub.com/coleifer/peewee/issues/1913).
[View commits](https://togithub.com/coleifer/peewee/compare/3.9.4...3.9.5)
### [`v3.9.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#394)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.3...3.9.4)
- Add `Model.bulk_update()` method for bulk-updating fields across multiple
model instances. [Docs](http://docs.peewee-orm.com/en/latest/peewee/api.html#Model.bulk_update).
- Add `lazy_load` parameter to `ForeignKeyField`. When initialized with
`lazy_load=False`, the foreign-key will not use an additional query to
resolve the related model instance. Instead, if the related model instance is
not available, the underlying FK column value is returned (behaving like the
"\_id" descriptor).
- Added `Model.truncate_table()` method.
- The `reflection` and `pwiz` extensions now attempt to be smarter about
converting database table and column names into snake-case. To disable this,
you can set `snake_case=False` when calling the `Introspector.introspect()`
method or use the `-L` (legacy naming) option with the `pwiz` script.
- Bulk insert via `insert_many()` no longer require specification of the
fields argument when the inserted rows are lists/tuples. In that case, the
fields will be inferred to be all model fields except any auto-increment id.
- Add `DatabaseProxy`, which implements several of the `Database` class context
managers. This allows you to reference some of the special features of the
database object without directly needing to initialize the proxy first.
- Add support for window function frame exclusion and added built-in support
for the GROUPS frame type.
- Add support for chaining window functions by extending a previously-declared
window function.
- Playhouse Postgresql extension `TSVectorField.match()` method supports an
additional argument `plain`, which can be used to control the parsing of the
TS query.
- Added very minimal `JSONField` to the playhouse MySQL extension.
[View commits](https://togithub.com/coleifer/peewee/compare/3.9.3...3.9.4)
### [`v3.9.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#393)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.2...3.9.3)
- Added cross-database support for `NULLS FIRST/LAST` when specifying the
ordering for a query. Previously this was only supported for Postgres. Peewee
will now generate an equivalent `CASE` statement for Sqlite and MySQL.
- Added [EXCLUDED](http://docs.peewee-orm.com/en/latest/peewee/api.html#EXCLUDED)
helper for referring to the `EXCLUDED` namespace used with `INSERT...ON CONFLICT`
queries, when referencing values in the conflicting row data.
- Added helper method to the model `Metadata` class for setting the table name
at run-time. Setting the `Model._meta.table_name` directly may have appeared
to work in some situations, but could lead to subtle bugs. The new API is
`Model._meta.set_table_name()`.
- Enhanced helpers for working with Peewee interactively, [see doc](http://docs.peewee-orm.com/en/latest/peewee/interactive.html).
- Fix cache invalidation bug in `DataSet` that was originally reported on the
sqlite-web project.
- New example script implementing a [hexastore](https://togithub.com/coleifer/peewee/blob/master/examples/hexastore.py).
[View commits](https://togithub.com/coleifer/peewee/compare/3.9.2...3.9.3)
### [`v3.9.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#391-and-392)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.1...3.9.2)
Includes a bugfix for an `AttributeError` that occurs when using MySQL with the
`MySQLdb` client. The 3.9.2 release includes fixes for a test failure.
[View commits](https://togithub.com/coleifer/peewee/compare/3.9.0...3.9.2)
### [`v3.9.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#391-and-392)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.0...3.9.1)
Includes a bugfix for an `AttributeError` that occurs when using MySQL with the
`MySQLdb` client. The 3.9.2 release includes fixes for a test failure.
[View commits](https://togithub.com/coleifer/peewee/compare/3.9.0...3.9.2)
### [`v3.9.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#390)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.8.2...3.9.0)
- Added new document describing how to [use peewee interactively](http://docs.peewee-orm.com/en/latest/peewee/interactive.html).
- 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 all `Query` 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 to `Field`
- Added `DatabaseProxy`, which allows one to use database-specific decorators
with an uninitialized `Proxy` object. See [#1842](https://togithub.com/coleifer/peewee/issues/1842) for discussion. Recommend
that you update any usage of `Proxy` for deferring database initialization to
use the new `DatabaseProxy` class instead.
- Added support for `INSERT ... ON CONFLICT` when the conflict target is a
partial index (e.g., contains a `WHERE` clause). The `OnConflict` and
`on_conflict()` APIs now take an additional `conflict_where` parameter to
represent the `WHERE` clause of the partial index in question. See [#1860](https://togithub.com/coleifer/peewee/issues/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 using `OR` instead of `AND`. See [#391](https://togithub.com/coleifer/peewee/issues/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](http://docs.peewee-orm.com/en/latest/peewee/api.html#SelectQuery.select_from).
- Added documentation on using [row values](http://docs.peewee-orm.com/en/latest/peewee/query_operators.html#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](https://togithub.com/coleifer/peewee/issues/1834) for details.
- Fixed bug where `TimestampField` would treat zero values as `None` when
reading from the database.
[View commits](https://togithub.com/coleifer/peewee/compare/3.8.2...3.9.0)
### [`v3.8.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#382)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.8.1...3.8.2)
**Backwards-incompatible changes**
- The default row-type for `INSERT` queries executed with a non-default
`RETURNING` clause has changed from `tuple` to `Model` instances. This makes
`INSERT` behavior consistent with `UPDATE` and `DELETE` queries that specify
a `RETURNING` clause. To revert back to the old behavior, just append a call
to `.tuples()` to your `INSERT ... RETURNING` query.
- Removing support for the `table_alias` model `Meta` option. Previously, this
attribute could be used to specify a "vanity" alias for a model class in the
generated SQL. As a result of some changes to support more robust UPDATE and
DELETE queries, supporting this feature will require some re-working. As of
the 3.8.0 release, it was broken and resulted in incorrect SQL for UPDATE
queries, so now it is removed.
**New features**
- Added `playhouse.shortcuts.ReconnectMixin`, which can be used to implement
automatic reconnect under certain error conditions (notably the MySQL error
2006 - server has gone away).
**Bugfixes**
- Fix SQL generation bug when using an inline window function in the `ORDER BY`
clause of a query.
- Fix possible zero-division in user-defined implementation of BM25 ranking
algorithm for SQLite full-text search.
[View commits](https://togithub.com/coleifer/peewee/compare/3.8.1...3.8.2)
### [`v3.8.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#381)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.8.0...3.8.1)
**New features**
- Sqlite `SearchField` now supports the `match()` operator, allowing full-text
search to be performed on a single column (as opposed to the whole table).
**Changes**
- Remove minimum passphrase restrictions in SQLCipher integration.
**Bugfixes**
- Support inheritance of `ManyToManyField` instances.
- Ensure operator overloads are invoked when generating filter expressions.
- Fix incorrect scoring in Sqlite BM25, BM25f and Lucene ranking algorithms.
- Support string field-names in data dictionary when performing an ON CONFLICT
... UPDATE query, which allows field-specific conversions to be applied.
References [#1815](https://togithub.com/coleifer/peewee/issues/1815).
[View commits](https://togithub.com/coleifer/peewee/compare/3.8.0...3.8.1)
### [`v3.8.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#380)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.7.1...3.8.0)
**New features**
- Postgres `BinaryJSONField` now supports `has_key()`, `concat()` and
`remove()` methods (though remove may require pg10+).
- Add `python_value()` method to the SQL-function helper `fn`, to allow
specifying a custom function for mapping database values to Python values.
**Changes**
- Better support for UPDATE ... FROM queries, and more generally, more robust
support for UPDATE and RETURNING clauses. This means that the
`QualifiedNames` helper is no longer needed for certain types of queries.
- The `SqlCipherDatabase` no longer accepts a `kdf_iter` parameter. To
configure the various SQLCipher encryption settings, specify the setting
values as `pragmas` when initializing the database.
- Introspection will now, by default, only strip "\_id" from introspected column
names if those columns are foreign-keys. See [#1799](https://togithub.com/coleifer/peewee/issues/1799) for discussion.
- Allow `UUIDField` and `BinaryUUIDField` to accept hexadecimal UUID strings as
well as raw binary UUID bytestrings (in addition to `UUID` instances, which
are already supported).
- Allow `ForeignKeyField` to be created without an index.
- Allow multiple calls to `cast()` to be chained ([#1795](https://togithub.com/coleifer/peewee/issues/1795)).
- Add logic to ensure foreign-key constraint names that exceed 64 characters
are truncated using the same logic as is currently in place for long indexes.
- `ManyToManyField` supports foreign-keys to fields other than primary-keys.
- When linked against SQLite 3.26 or newer, support `SQLITE_CONSTRAINT` to
designate invalid queries against virtual tables.
- SQL-generation changes to aid in supporting using queries within expressions
following the SELECT statement.
**Bugfixes**
- Fixed bug in `order_by_extend()`, thanks [@nhatHero](https://togithub.com/nhatHero).
- Fixed bug where the `DataSet` CSV import/export did not support non-ASCII
characters in Python 3.x.
- Fixed bug where `model_to_dict` would attempt to traverse explicitly disabled
foreign-key backrefs ([#1785](https://togithub.com/coleifer/peewee/issues/1785)).
- Fixed bug when attempting to migrate SQLite tables that have a field whose
column-name begins with "primary\_".
- Fixed bug with inheriting deferred foreign-keys.
[View commits](https://togithub.com/coleifer/peewee/compare/3.7.1...3.8.0)
### [`v3.7.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#371)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.7.0...3.7.1)
**New features**
- Added `table_settings` model `Meta` option, which should be a list of strings
specifying additional options for `CREATE TABLE`, which are placed *after*
the closing parentheses.
- Allow specification of `on_update` and `on_delete` behavior for many-to-many
relationships when using `ManyToManyField`.
**Bugfixes**
- Fixed incorrect SQL generation for Postgresql ON CONFLICT clause when the
conflict_target is a named constraint (rather than an index expression). This
introduces a new keyword-argument to the `on_conflict()` method:
`conflict_constraint`, which is currently only supported by Postgresql. Refs
issue [#1737](https://togithub.com/coleifer/peewee/issues/1737).
- Fixed incorrect SQL for sub-selects used on the right side of `IN`
expressions. Previously the query would be assigned an alias, even though an
alias was not needed.
- Fixed incorrect SQL generation for Model indexes which contain SQL functions
as indexed columns.
- Fixed bug in the generation of special queries used to perform operations on
SQLite FTS5 virtual tables.
- Allow `frozenset` to be correctly parameterized as a list of values.
- Allow multi-value INSERT queries to specify `columns` as a list of strings.
- Support `CROSS JOIN` for model select queries.
[View commits](https://togithub.com/coleifer/peewee/compare/3.7.0...3.7.1)
### [`v3.7.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#370)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.4...3.7.0)
**Backwards-incompatible changes**
- Pool database `close_all()` method renamed to `close_idle()` to better
reflect the actual behavior.
- Databases will now raise `InterfaceError` when `connect()` or `close()` are
called on an uninitialized, deferred database object.
**New features**
- Add methods to the migrations extension to support adding and dropping table
constraints.
- Add [Model.bulk_create()](http://docs.peewee-orm.com/en/latest/peewee/api.html#Model.bulk_create)
method for bulk-inserting unsaved model instances.
- Add `close_stale()` method to the connection pool to support closing stale
connections.
- The `FlaskDB` class in `playhouse.flask_utils` now accepts a `model_class`
parameter, which can be used to specify a custom base-class for models.
**Bugfixes**
- Parentheses were not added to subqueries used in function calls with more
than one argument.
- Fixed bug when attempting to serialize many-to-many fields which were created
initially with a `DeferredThroughModel`, see [#1708](https://togithub.com/coleifer/peewee/issues/1708).
- Fixed bug when using the Postgres `ArrayField` with an array of `BlobField`.
- Allow `Proxy` databases to be used as a context-manager.
- Fixed bug where the APSW driver was referring to the SQLite version from the
standard library `sqlite3` driver, rather than from `apsw`.
- Reflection library attempts to wrap server-side column defaults in quotation
marks if the column data-type is text/varchar.
- Missing import in migrations library, which would cause errors when
attempting to add indexes whose name exceeded 64 chars.
- When using the Postgres connection pool, ensure any open/pending transactions
are rolled-back when the connection is recycled.
- Even *more* changes to the `setup.py` script. In this case I've added a
helper function which will reliably determine if the SQLite3 extensions can
be built. This follows the approach taken by the Python YAML package.
[View commits](https://togithub.com/coleifer/peewee/compare/3.6.4...3.7.0)
### [`v3.6.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#364)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.3...3.6.4)
Take a whole new approach, following what `simplejson` does. Allow the
`build_ext` command class to fail, and retry without extensions in the event we
run into issues building extensions. References [#1676](https://togithub.com/coleifer/peewee/issues/1676).
[View commits](https://togithub.com/coleifer/peewee/compare/3.6.3...3.6.4)
### [`v3.6.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#363)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.2...3.6.3)
Add check in `setup.py` to determine if a C compiler is available before
building C extensions. References [#1676](https://togithub.com/coleifer/peewee/issues/1676).
[View commits](https://togithub.com/coleifer/peewee/compare/3.6.2...3.6.3)
### [`v3.6.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#362)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.1...3.6.2)
Use `ctypes.util.find_library` to determine if `libsqlite3` is installed.
Should fix problems people are encountering installing when SQLite3 is not
available.
[View commits](https://togithub.com/coleifer/peewee/compare/3.6.1...3.6.2)
### [`v3.6.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#361)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.0...3.6.1)
Fixed issue with setup script.
[View commits](https://togithub.com/coleifer/peewee/compare/3.6.0...3.6.1)
### [`v3.6.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#360)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.5.2...3.6.0)
- Support for Python 3.7, including bugfixes related to new StopIteration
handling inside of generators.
- Support for specifying `ROWS` or `RANGE` window frame types. For more
information, see the new [frame type documentation](http://docs.peewee-orm.com/en/latest/peewee/querying.html#frame-types-range-vs-rows).
- Add APIs for user-defined window functions if using [pysqlite3](https://togithub.com/coleifer/pysqlite3)
and sqlite 3.25.0 or newer.
- `TimestampField` now uses 64-bit integer data-type for storage.
- Added support to `pwiz` and `playhouse.reflection` to enable generating
models from VIEWs.
- Added lower-level database API for introspecting VIEWs.
- Revamped continuous integration setup for better coverage, including 3.7 and
3.8-dev.
- Allow building C extensions even if Cython is not installed, by distributing
pre-generated C source files.
- Switch to using `setuptools` for packaging.
[View commits](https://togithub.com/coleifer/peewee/compare/3.5.2...3.6.0)
### [`v3.5.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#352)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.5.1...3.5.2)
- New guide to using [window functions in Peewee](http://docs.peewee-orm.com/en/latest/peewee/querying.html#window-functions).
- New and improved table name auto-generation. This feature is not backwards
compatible, so it is **disabled by default**. To enable, set
`legacy_table_names=False` in your model's `Meta` options. For more details,
see [table names](http://docs.peewee-orm.com/en/latest/peewee/models.html#table_names)
documentation.
- Allow passing single fields/columns to window function `order_by` and
`partition_by` arguments.
- Support for `FILTER (WHERE...)` clauses with window functions and aggregates.
- Added `IdentityField` class suitable for use with Postgres 10's new identity
column type. It can be used anywhere `AutoField` or `BigAutoField` was being
used previously.
- Fixed bug creating indexes on tables that are in attached databases (SQLite).
- Fixed obscure bug when using `prefetch()` and `ModelAlias` to populate a
back-reference related model.
[View commits](https://togithub.com/coleifer/peewee/compare/3.5.1...3.5.2)
### [`v3.5.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#351)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.5.0...3.5.1)
**New features**
- New documentation for working with [relationships](http://docs.peewee-orm.com/en/latest/peewee/relationships.html)
in Peewee.
- Improved tests and documentation for MySQL upsert functionality.
- Allow `database` parameter to be specified with `ModelSelect.get()` method.
For discussion, see [#1620](https://togithub.com/coleifer/peewee/issues/1620).
- Add `QualifiedNames` helper to peewee module exports.
- Add `temporary=` meta option to support temporary tables.
- Allow a `Database` object to be passed to constructor of `DataSet` helper.
**Bug fixes**
- Fixed edge-case where attempting to alias a field to it's underlying
column-name (when different), Peewee would not respect the alias and use the
field name instead. See [#1625](https://togithub.com/coleifer/peewee/issues/1625) for details and discussion.
- Raise a `ValueError` when joining and aliasing the join to a foreign-key's
`object_id_name` descriptor. Should prevent accidentally introducing O(n)
queries or silently ignoring data from a joined-instance.
- Fixed bug for MySQL when creating a foreign-key to a model which used the
`BigAutoField` for it's primary-key.
- Fixed bugs in the implementation of user-defined aggregates and extensions
with the APSW SQLite driver.
- Fixed regression introduced in 3.5.0 which ignored custom Model `__repr__()`.
- Fixed regression from 2.x in which inserting from a query using a `SQL()` was
no longer working. Refs [#1645](https://togithub.com/coleifer/peewee/issues/1645).
[View commits](https://togithub.com/coleifer/peewee/compare/3.5.0...3.5.1)
### [`v3.5.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#350)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.4.0...3.5.0)
**Backwards-incompatible changes**
- Custom Model `repr` no longer use the convention of overriding `__unicode__`,
and now use `__str__`.
- Redesigned the [sqlite json1 integration](http://docs.peewee-orm.com/en/latest/peewee/sqlite_ext.html#sqlite-json1).
and changed some of the APIs and semantics of various `JSONField` methods.
The documentation has been expanded to include more examples and the API has
been simplified to make it easier to work with. These changes **do not** have
any effect on the [Postgresql JSON fields](http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#pgjson).
**New features**
- Better default `repr` for model classes and fields.
- `ForeignKeyField()` accepts a new initialization parameter, `deferrable`, for
specifying when constraints should be enforced.
- `BitField.flag()` can be called without a value parameter for the common
use-case of using flags that are powers-of-2.
- `SqliteDatabase` pragmas can be specified as a `dict` (previously required a
list of 2-tuples).
- SQLite `TableFunction` ([docs](http://docs.peewee-orm.com/en/latest/peewee/sqlite_ext.html#sqlite-vtfunc))
will print Python exception tracebacks raised in the `initialize` and
`iterate` callbacks, making debugging significantly easier.
**Bug fixes**
- Fixed bug in `migrator.add_column()` where, if the field being added declared
a non-standard index type (e.g., binary json field with GIN index), this
index type was not being respected.
- Fixed bug in `database.table_exists()` where the implementation did not match
the documentation. Implementation has been updated to match the
documentation.
- Fixed bug in SQLite `TableFunction` implementation which raised errors if the
return value of the `iterate()` method was not a `tuple`.
[View commits](https://togithub.com/coleifer/peewee/compare/3.4.0...3.5.0)
### [`v3.4.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#340)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.4...3.4.0)
**Backwards-incompatible changes**
- The `regexp()` operation is now case-sensitive for MySQL and Postgres. To
perform case-insensitive regexp operations, use `iregexp()`.
- The SQLite `BareField()` field-type now supports all column constraints
*except* specifying the data-type. Previously it silently ignored any column
constraints.
- LIMIT and OFFSET parameters are now treated as parameterized values instead
of literals.
- The `schema` parameter for SQLite database introspection methods is no longer
ignored by default. The schema corresponds to the name given to an attached
database.
- `ArrayField` now accepts a new parameter `field_kwargs`, which is used to
pass information to the array field's `field_class` initializer.
**New features and other changes**
- SQLite backup interface supports specifying page-counts and a user-defined
progress handler.
- GIL is released when doing backups or during SQLite busy timeouts (when using
the peewee SQLite busy-handler).
- Add NATURAL join-type to the `JOIN` helper.
- Improved identifier quoting to allow specifying distinct open/close-quote
characters. Enables adding support for MSSQL, for instance, which uses square
brackets, e.g. `[table].[column]`.
- Unify timeout interfaces for SQLite databases (use seconds everywhere rather
than mixing seconds and milliseconds, which was confusing).
- Added `attach()` and `detach()` methods to SQLite database, making it
possible to attach additional databases (e.g. an in-memory cache db).
[View commits](https://togithub.com/coleifer/peewee/compare/3.3.4...3.4.0)
### [`v3.3.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#334)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.3...3.3.4)
- Added a `BinaryUUIDField` class for efficiently storing UUIDs in 16-bytes.
- Fix dataset's `update_cache()` logic so that when updating a single table
that was newly-added, we also ensure that all dependent tables are updated at
the same time. Refs [coleifer/sqlite-web#42](https://togithub.com/coleifer/sqlite-web/issues/42).
[View commits](https://togithub.com/coleifer/peewee/compare/3.3.3...3.3.4)
### [`v3.3.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#333)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.2...3.3.3)
- More efficient implementation of model dependency-graph generation. Improves
performance of recursively deleting related objects by omitting unnecessary
subqueries.
- Added `union()`, `union_all()`, `intersect()` and `except_()` to the
`Model`-specific query implementations. This was an oversight that should
have been patched in 3.3.2, but is fixed in 3.3.3.
- Major cleanup to test runner and standardized test skipping logic to
integrate with standard-library `unittest` conventions.
[View commits](https://togithub.com/coleifer/peewee/compare/3.3.2...3.3.3)
### [`v3.3.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#332)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.1...3.3.2)
- Add methods for `union()`, `union_all`, `intersect()` and `except_()`.
Previously, these methods were only available as operator overloads.
- Removed some Python 2.6-specific support code, as 2.6 is no longer officially
supported.
- Fixed model-graph resolution logic for deferred foreign-keys.
- Better support for UPDATE...FROM queries (Postgresql).
[View commits](https://togithub.com/coleifer/peewee/compare/3.3.1...3.3.2)
### [`v3.3.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#331)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.0...3.3.1)
- Fixed long-standing bug in 3.x regarding using column aliases with queries
that utilize the ModelCursorWrapper (typically queries with one or more
joins).
- Fix typo in model metadata code, thanks [@klen](https://togithub.com/klen).
- Add examples of using recursive CTEs to docs.
[View commits](https://togithub.com/coleifer/peewee/compare/3.3.0...3.3.1)
### [`v3.3.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#330)
[Compare Source](https://togithub.com/coleifer/peewee/compare/3.2.5...3.3.0)
- Added support for SQLite's new `ON CONFLICT` clause, which is modelled on the
syntax used by Postgresql and will be available in SQLite 3.24.0 and onward.
- Added better support for using common table expressions and a cleaner way of
implementing recursive CTEs, both of which are also tested with integration
tests (as opposed to just checking the
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
==3.2.2
->==3.16.2
Release Notes
coleifer/peewee
### [`v3.16.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3162) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.16.1...3.16.2) Fixes a longstanding issue with thread-safety of various decorators, including `atomic()`, `transaction()`, `savepoint()`. The context-managers are unaffected. See [#2709](https://togithub.com/coleifer/peewee/issues/2709) for details. [View commits](https://togithub.com/coleifer/peewee/compare/3.16.1...3.16.2) ### [`v3.16.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3161) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.16.0...3.16.1) - Add changes required for building against Cython 3.0 and set Cython language-level to 3. - Ensure indexes aren't added to unindexed fields during introspection, [#2691](https://togithub.com/coleifer/peewee/issues/2691). - Ensure we don't redundantly select same PK in prefetch when using PREFETCH_TYPE.JOIN. - In Sqlite migrator, use Sqlite's builtin DROP and RENAME column facilities when possible. This can be overridden by passing `legacy=True` flag. [View commits](https://togithub.com/coleifer/peewee/compare/3.16.0...3.16.1) ### [`v3.16.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3160) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.4...3.16.0) This release contains backwards-incompatible changes in the way Peewee initializes connections to the underlying database driver. Previously, peewee implemented autocommit semantics *on-top* of the existing DB-API transactional workflow. Going forward, Peewee instead places the DB-API driver into autocommit mode directly. Why this change? Previously, Peewee emulated autocommit behavior for top-level queries issued outside of a transaction. This necessitated a number of checks which had to be performed each time a query was executed, so as to ensure that we didn't end up with uncommitted writes or, conversely, idle read transactions. By running the underlying driver in autocommit mode, we can eliminate all these checks, since we are already managing transactions ourselves. Behaviorally, there should be no change -- Peewee will still treat top-level queries outside of transactions as being autocommitted, while queries inside of `atomic()` / `with db:` blocks are implicitly committed at the end of the block, or rolled-back if an exception occurs. **How might this affect me?** - If you are using the underlying database connection or cursors, e.g. via `Database.connection()` or `Database.cursor()`, your queries will now be executed in autocommit mode. - The `commit=` argument is deprecated for the `cursor()`, `execute()` and `execute_sql()` methods. - If you have a custom `Database` implementation (whether for a database that is not officially supported, or for the purpose of overriding default behaviors), you will want to ensure that your connections are opened in autocommit mode. Other changes: - Some fixes to help with packaging in Python 3.11. - MySQL `get_columns()` implementation now returns columns in their declared order. [View commits](https://togithub.com/coleifer/peewee/compare/3.15.4...3.16.0) ### [`v3.15.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3154) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.3...3.15.4) - Raise an exception in `ReconnectMixin` if connection is lost while inside a transaction (if the transaction was interrupted presumably some changes were lost and explicit intervention is needed). - Add `db.Model` property to reduce boilerplate. - Add support for running `prefetch()` queries with joins instead of subqueries (this helps overcome a MySQL limitation about applying LIMITs to a subquery). - Add SQL `AVG` to whitelist to avoid coercing by default. - Allow arbitrary keywords in metaclass constructor, [#2627](https://togithub.com/coleifer/peewee/issues/2627) - Add a `pyproject.toml` to silence warnings from newer pips when `wheel` package is not available. This release has a small helper for reducing boilerplate in some cases by exposing a base model class as an attribute of the database instance. ```python ``` ### [`v3.15.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3153) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.2...3.15.3) - Add `scalars()` query method (complements `scalar()`), roughly equivalent to writing `[t[0] for t in query.tuples()]`. - Small doc improvements - Fix and remove some flaky test assertions with Sqlite INSERT + RETURNING. - Fix innocuous failing Sqlite test on big-endian machines. [View commits](https://togithub.com/coleifer/peewee/compare/3.15.2...3.15.3) ### [`v3.15.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3152) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.1...3.15.2) - Fix bug where field-specific conversions were being applied to the pattern used for LIKE / ILIKE operations. Refs [#2609](https://togithub.com/coleifer/peewee/issues/2609) - Fix possible infinite loop when accidentally invoking the `__iter__` method on certain `Column` subclasses. Refs [#2606](https://togithub.com/coleifer/peewee/issues/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](https://togithub.com/coleifer/peewee/compare/3.15.1...3.15.2) ### [`v3.15.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3151) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.15.0...3.15.1) - Fix issue introduced in Sqlite 3.39.0 regarding the propagation of column subtypes in subqueries. - Fix bug where cockroachdb server version was not set when beginning a transaction on an unopened database. [View commits](https://togithub.com/coleifer/peewee/compare/3.15.0...3.15.1) ### [`v3.15.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3150) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.10...3.15.0) Rollback behavior change in commit [`ab43376`](https://togithub.com/coleifer/peewee/commit/ab43376697) (GH [#2026](https://togithub.com/coleifer/peewee/issues/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: ```python ``` ### [`v3.14.10`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#Previous-behavior-peewee-312---31410-) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.9...3.14.10) ### Previous behavior (peewee 3.12 - 3.14.10): ### [`v3.14.9`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3149) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.8...3.14.9) - 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](https://togithub.com/coleifer/peewee/compare/3.14.8...3.14.9) ### [`v3.14.8`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3148) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.7...3.14.8) 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](https://togithub.com/coleifer/peewee/compare/3.14.7...3.14.8) ### [`v3.14.7`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3147) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.6...3.14.7) Fix bug in APSW extension with Sqlite 3.35 and newer, due to handling of last insert rowid with RETURNING. Refs [#2479](https://togithub.com/coleifer/peewee/issues/2479). [View commits](https://togithub.com/coleifer/peewee/compare/3.14.6...3.14.7) ### [`v3.14.6`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3146) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.4...3.14.6) Fix pesky bug in new `last_insert_id()` on the `SqliteExtDatabase`. [View commits](https://togithub.com/coleifer/peewee/compare/3.14.5...3.14.6) ### [`v3.14.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3144) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.3...3.14.4) This release contains an important fix for a regression introduced by commit [`ebe3ad5`](https://togithub.com/coleifer/peewee/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](https://togithub.com/coleifer/peewee/issues/2376). [View commits](https://togithub.com/coleifer/peewee/compare/3.14.3...3.14.4) ### [`v3.14.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3143) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.2...3.14.3) This release contains a single fix for ensuring NULL values are inserted when issuing a bulk-insert of heterogeneous dictionaries which may be missing explicit NULL values. Fixes issue [#2638](https://togithub.com/coleifer/peewee/issues/2638). [View commits](https://togithub.com/coleifer/peewee/compare/3.14.2...3.14.3) ### [`v3.14.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3142) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.1...3.14.2) This is a small release mainly to get some fixes out. - Support for named `Check` and foreign-key constraints. - Better foreign-key introspection for CockroachDB (and Postgres). - Register UUID adapter for Postgres. - Add `fn.array_agg()` to blacklist for automatic value coercion. [View commits](https://togithub.com/coleifer/peewee/compare/3.14.1...3.14.2) ### [`v3.14.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#Previous-behavior-peewee-312---31410-) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.14.0...3.14.1) ### Previous behavior (peewee 3.12 - 3.14.10): ### [`v3.14.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3140) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.13.3...3.14.0) This release has been a bit overdue and there are numerous small improvements and bug-fixes. The bugfix that prompted this release is [#2293](https://togithub.com/coleifer/peewee/issues/2293), which is a regression in the Django-inspired `.filter()` APIs that could cause some filter expressions to be discarded from the generated SQL. Many thanks for the excellent bug report, Jakub. - Add an experimental helper, `shortcuts.resolve_multimodel_query()`, for resolving multiple models used in a compound select query. - Add a `lateral()` method to select query for use with lateral joins, refs issue [#2205](https://togithub.com/coleifer/peewee/issues/2205). - Added support for nested transactions (savepoints) in cockroach-db (requires 20.1 or newer). - Automatically escape wildcards passed to string-matching methods, refs [#2224](https://togithub.com/coleifer/peewee/issues/2224). - Allow index-type to be specified on MySQL, refs [#2242](https://togithub.com/coleifer/peewee/issues/2242). - Added a new API, `converter()` to be used for specifying a function to use to convert a row-value pulled off the cursor, refs [#2248](https://togithub.com/coleifer/peewee/issues/2248). - Add `set()` and `clear()` method to the bitfield flag descriptor, refs [#2257](https://togithub.com/coleifer/peewee/issues/2257). - Add support for `range` types with `IN` and other expressions. - Support CTEs bound to compound select queries, refs [#2289](https://togithub.com/coleifer/peewee/issues/2289). ##### Bug-fixes - Fix to return related object id when accessing via the object-id descriptor, when the related object is not populated, refs [#2162](https://togithub.com/coleifer/peewee/issues/2162). - Fix to ensure we do not insert a NULL value for a primary key. - Fix to conditionally set the field/column on an added column in a migration, refs [#2171](https://togithub.com/coleifer/peewee/issues/2171). - Apply field conversion logic to model-class values. Relocates the logic from issue [#2131](https://togithub.com/coleifer/peewee/issues/2131) and fixes [#2185](https://togithub.com/coleifer/peewee/issues/2185). - Clone node before modifying it to be flat in an enclosed nodelist expr, fixes issue [#2200](https://togithub.com/coleifer/peewee/issues/2200). - Fix an invalid item assignment in nodelist, refs [#2220](https://togithub.com/coleifer/peewee/issues/2220). - Fix an incorrect truthiness check used with `save()` and `only=`, refs [#2269](https://togithub.com/coleifer/peewee/issues/2269). - Fix regression in `filter()` where using both `*args` and `**kwargs` caused the expressions passed as `args` to be discarded. See [#2293](https://togithub.com/coleifer/peewee/issues/2293). [View commits](https://togithub.com/coleifer/peewee/compare/3.13.3...3.14.0) ### [`v3.13.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3133) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.13.2...3.13.3) - Allow arbitrary keyword arguments to be passed to `DataSet` constructor, which are then passed to the instrospector. - Allow scalar subqueries to be compared using numeric operands. - Fix `bulk_create()` when model being inserted uses FK identifiers. - Fix `bulk_update()` so that PK values are properly coerced to the right data-type (e.g. UUIDs to strings for Sqlite). - Allow array indices to be used as dict keys, e.g. for the purposes of updating a single array index value. [View commits](https://togithub.com/coleifer/peewee/compare/3.13.2...3.13.3) ### [`v3.13.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3132) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.13.1...3.13.2) - Allow aggregate functions to support an `ORDER BY` clause, via the addition of an `order_by()` method to the function (`fn`) instance. Refs [#2094](https://togithub.com/coleifer/peewee/issues/2094). - Fix `prefetch()` bug, where related "backref" instances were marked as dirty, even though they had no changes. Fixes [#2091](https://togithub.com/coleifer/peewee/issues/2091). - Support `LIMIT 0`. Previously a limit of 0 would be translated into effectively an unlimited query on MySQL. References [#2084](https://togithub.com/coleifer/peewee/issues/2084). - Support indexing into arrays using expressions with Postgres array fields. References [#2085](https://togithub.com/coleifer/peewee/issues/2085). - Ensure postgres introspection methods return the columns for multi-column indexes in the correct order. Fixes [#2104](https://togithub.com/coleifer/peewee/issues/2104). - Add support for arrays of UUIDs to postgres introspection. - Fix introspection of columns w/capitalized table names in postgres ([#2110](https://togithub.com/coleifer/peewee/issues/2110)). - Fix to ensure correct exception is raised in SqliteQueueDatabase when iterating over cursor/result-set. - Fix bug comparing subquery against a scalar value. Fixes [#2118](https://togithub.com/coleifer/peewee/issues/2118). - Fix issue resolving composite primary-keys that include foreign-keys when building the model-graph. Fixes [#2115](https://togithub.com/coleifer/peewee/issues/2115). - Allow model-classes to be passed as arguments, e.g., to a table function. Refs [#2131](https://togithub.com/coleifer/peewee/issues/2131). - Ensure postgres `JSONField.concat()` accepts expressions as arguments. [View commits](https://togithub.com/coleifer/peewee/compare/3.13.1...3.13.2) ### [`v3.13.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3131) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.13.0...3.13.1) Fix a regression when specifying keyword arguments to the `atomic()` or `transaction()` helper methods. Note: this only occurs if you were using Sqlite and were explicitly setting the `lock_type=` parameter. [View commits](https://togithub.com/coleifer/peewee/compare/3.13.0...3.13.1) ### [`v3.13.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3130) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.12.0...3.13.0) ##### CockroachDB support added This will be a notable release as it adds support for [CockroachDB](https://cockroachlabs.com/), a distributed, horizontally-scalable SQL database. - [CockroachDB usage overview](http://docs.peewee-orm.com/en/latest/peewee/database.html#using-crdb) - [CockroachDB API documentation](http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#crdb) ##### Other features and fixes - Allow `FOR UPDATE` clause to specify one or more tables (`FOR UPDATE OF...`). - Support for Postgres `LATERAL` join. - Properly wrap exceptions raised during explicit commit/rollback in the appropriate peewee-specific exception class. - Capture original exception object and expose it as `exc.orig` on the wrapped exception. - Properly introspect `SMALLINT` columns in Postgres schema reflection. - More flexible handling of passing database-specific arguments to `atomic()` and `transaction()` context-manager/decorator. - Fix non-deterministic join ordering issue when using the `filter()` API across several tables ([#2063](https://togithub.com/coleifer/peewee/issues/2063)). [View commits](https://togithub.com/coleifer/peewee/compare/3.12.0...3.13.0) ### [`v3.12.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3120) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.11.2...3.12.0) - Bulk insert (`insert_many()` and `insert_from()`) will now return the row count instead of the last insert ID. If you are using Postgres, peewee will continue to return a cursor that provides an iterator over the newly-inserted primary-key values by default. This behavior is being retained by default for compatibility. Postgres users can simply specify an empty `returning()` call to disable the cursor and retrieve the rowcount instead. - Migration extension now supports altering a column's data-type, via the new `alter_column_type()` method. - Added `Database.is_connection_usabe()` method, which attempts to look at the status of the underlying DB-API connection to determine whether the connection is usable. - Common table expressions include a `materialized` parameter, which can be used to control Postgres' optimization fencing around CTEs. - Added `BloomFilter.from_buffer()` method for populating a bloom-filter from the output of a previous call to the `to_buffer()` method. - Fixed APSW extension's `commit()` and `rollback()` methods to no-op if the database is in auto-commit mode. - Added `generate_always=` option to the `IdentityField` (defaults to False). [View commits](https://togithub.com/coleifer/peewee/compare/3.11.2...3.12.0) ### [`v3.11.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3112) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.11.1...3.11.2) - Implement `hash` interface for `Alias` instances, allowing them to be used in multi-source queries. [View commits](https://togithub.com/coleifer/peewee/compare/3.11.1...3.11.2) ### [`v3.11.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3111) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.11.0...3.11.1) - Fix bug in new `_pk` / `get_id()` implementation for models that explicitly have disabled a primary-key. [View commits](https://togithub.com/coleifer/peewee/compare/3.11.0...3.11.1) ### [`v3.11.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3110) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.10.0...3.11.0) - Fixes [#1991](https://togithub.com/coleifer/peewee/issues/1991). This particular issue involves joining 3 models together in a chain, where the outer two models are empty. Previously peewee would make the middle model an empty model instance (since a link might be needed from the source model to the outermost model). But since both were empty, it is more correct to make the intervening model a NULL value on the foreign-key field rather than an empty instance. - An unrelated fix came out of the work on [#1991](https://togithub.com/coleifer/peewee/issues/1991) where hashing a model whose primary-key happened to be a foreign-key could trigger the FK resolution query. This patch fixes the `Model._pk` and `get_id()` interfaces so they no longer introduce the possibility of accidentally resolving the FK. - Allow `Field.contains()`, `startswith()` and `endswith()` to compare against another column-like object or expression. - Workaround for MySQL prior to 8 and MariaDB handling of union queries inside of parenthesized expressions (like IN). - Be more permissive in letting invalid values be stored in a field whose type is INTEGER or REAL, since Sqlite allows this. - `TimestampField` resolution cleanup. Now values 0 *and* 1 will resolve to a timestamp resolution of 1 second. Values 2-6 specify the number of decimal places (hundredths to microsecond), or alternatively the resolution can still be provided as a power of 10, e.g. 10, 1000 (millisecond), 1e6 (microsecond). - When self-referential foreign-keys are inherited, the foreign-key on the subclass will also be self-referential (rather than pointing to the parent model). - Add TSV import/export option to the `dataset` extension. - Add item interface to the `dataset.Table` class for doing primary-key lookup, assignment, or deletion. - Extend the mysql `ReconnectMixin` helper to work with mysql-connector. - Fix mapping of double-precision float in postgres schema reflection. Previously it mapped to single-precision, now it correctly uses a double. - Fix issue where `PostgresqlExtDatabase` and `MySQLConnectorDatabase` did not respect the `autoconnect` setting. [View commits](https://togithub.com/coleifer/peewee/compare/3.10.0...3.11.0) ### [`v3.10.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#3100) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.6...3.10.0) - Add a helper to `playhouse.mysql_ext` for creating `Match` full-text search expressions. - Added date-part properties to `TimestampField` for accessing the year, month, day, etc., within a SQL expression. - Added `to_timestamp()` helper for `DateField` and `DateTimeField` that produces an expression returning a unix timestamp. - Add `autoconnect` parameter to `Database` classes. This parameter defaults to `True` and is compatible with previous versions of Peewee, in which executing a query on a closed database would open a connection automatically. To make it easier to catch inconsistent use of the database connection, this behavior can now be disabled by specifying `autoconnect=False`, making an explicit call to `Database.connect()` needed before executing a query. - Added database-agnostic interface for obtaining a random value. - Allow `isolation_level` to be specified when initializing a Postgres db. - Allow hybrid properties to be used on model aliases. Refs [#1969](https://togithub.com/coleifer/peewee/issues/1969). - Support aggregates with FILTER predicates on the latest Sqlite. ##### Changes - More aggressively slot row values into the appropriate field when building objects from the database cursor (rather than using whatever `cursor.description` tells us, which is buggy in older Sqlite). - Be more permissive in what we accept in the `insert_many()` and `insert()` methods. - When implicitly joining a model with multiple foreign-keys, choose the foreign-key whose name matches that of the related model. Previously, this would have raised a `ValueError` stating that multiple FKs existed. - Improved date truncation logic for Sqlite and MySQL to make more compatible with Postgres' `date_trunc()` behavior. Previously, truncating a datetime to month resolution would return `'2019-08'` for example. As of 3.10.0, the Sqlite and MySQL `date_trunc` implementation returns a full datetime, e.g. `'2019-08-01 00:00:00'`. - Apply slightly different logic for casting JSON values with Postgres. Previously, Peewee just wrapped the value in the psycopg2 `Json()` helper. In this version, Peewee now dumps the json to a string and applies an explicit cast to the underlying JSON data-type (e.g. json or jsonb). ##### Bug fixes - Save hooks can now be called for models without a primary key. - Fixed bug in the conversion of Python values to JSON when using Postgres. - Fix for differentiating empty values from NULL values in `model_to_dict`. - Fixed a bug referencing primary-key values that required some kind of conversion (e.g., a UUID). See [#1979](https://togithub.com/coleifer/peewee/issues/1979) for details. - Add small jitter to the pool connection timestamp to avoid issues when multiple connections are checked-out at the same exact time. [View commits](https://togithub.com/coleifer/peewee/compare/3.9.6...3.10.0) ### [`v3.9.6`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#396) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.5...3.9.6) - Support nesting the `Database` instance as a context-manager. The outermost block will handle opening and closing the connection along with wrapping everything in a transaction. Nested blocks will use savepoints. - Add new `session_start()`, `session_commit()` and `session_rollback()` interfaces to the Database object to support using transactional controls in situations where a context-manager or decorator is awkward. - Fix error that would arise when attempting to do an empty bulk-insert. - Set `isolation_level=None` in SQLite connection constructor rather than afterwards using the setter. - Add `create_table()` method to `Select` query to implement `CREATE TABLE AS`. - Cleanup some declarations in the Sqlite C extension. - Add new example showing how to implement Reddit's ranking algorithm in SQL. [View commits](https://togithub.com/coleifer/peewee/compare/3.9.5...3.9.6) ### [`v3.9.5`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#395) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.4...3.9.5) - Added small helper for setting timezone when using Postgres. - Improved SQL generation for `VALUES` clause. - Support passing resolution to `TimestampField` as a power-of-10. - Small improvements to `INSERT` queries when the primary-key is not an auto-incrementing integer, but is generated by the database server (eg uuid). - Cleanups to virtual table implementation and python-to-sqlite value conversions. - Fixed bug related to binding previously-unbound models to a database using a context manager, [#1913](https://togithub.com/coleifer/peewee/issues/1913). [View commits](https://togithub.com/coleifer/peewee/compare/3.9.4...3.9.5) ### [`v3.9.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#394) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.3...3.9.4) - Add `Model.bulk_update()` method for bulk-updating fields across multiple model instances. [Docs](http://docs.peewee-orm.com/en/latest/peewee/api.html#Model.bulk_update). - Add `lazy_load` parameter to `ForeignKeyField`. When initialized with `lazy_load=False`, the foreign-key will not use an additional query to resolve the related model instance. Instead, if the related model instance is not available, the underlying FK column value is returned (behaving like the "\_id" descriptor). - Added `Model.truncate_table()` method. - The `reflection` and `pwiz` extensions now attempt to be smarter about converting database table and column names into snake-case. To disable this, you can set `snake_case=False` when calling the `Introspector.introspect()` method or use the `-L` (legacy naming) option with the `pwiz` script. - Bulk insert via `insert_many()` no longer require specification of the fields argument when the inserted rows are lists/tuples. In that case, the fields will be inferred to be all model fields except any auto-increment id. - Add `DatabaseProxy`, which implements several of the `Database` class context managers. This allows you to reference some of the special features of the database object without directly needing to initialize the proxy first. - Add support for window function frame exclusion and added built-in support for the GROUPS frame type. - Add support for chaining window functions by extending a previously-declared window function. - Playhouse Postgresql extension `TSVectorField.match()` method supports an additional argument `plain`, which can be used to control the parsing of the TS query. - Added very minimal `JSONField` to the playhouse MySQL extension. [View commits](https://togithub.com/coleifer/peewee/compare/3.9.3...3.9.4) ### [`v3.9.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#393) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.2...3.9.3) - Added cross-database support for `NULLS FIRST/LAST` when specifying the ordering for a query. Previously this was only supported for Postgres. Peewee will now generate an equivalent `CASE` statement for Sqlite and MySQL. - Added [EXCLUDED](http://docs.peewee-orm.com/en/latest/peewee/api.html#EXCLUDED) helper for referring to the `EXCLUDED` namespace used with `INSERT...ON CONFLICT` queries, when referencing values in the conflicting row data. - Added helper method to the model `Metadata` class for setting the table name at run-time. Setting the `Model._meta.table_name` directly may have appeared to work in some situations, but could lead to subtle bugs. The new API is `Model._meta.set_table_name()`. - Enhanced helpers for working with Peewee interactively, [see doc](http://docs.peewee-orm.com/en/latest/peewee/interactive.html). - Fix cache invalidation bug in `DataSet` that was originally reported on the sqlite-web project. - New example script implementing a [hexastore](https://togithub.com/coleifer/peewee/blob/master/examples/hexastore.py). [View commits](https://togithub.com/coleifer/peewee/compare/3.9.2...3.9.3) ### [`v3.9.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#391-and-392) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.1...3.9.2) Includes a bugfix for an `AttributeError` that occurs when using MySQL with the `MySQLdb` client. The 3.9.2 release includes fixes for a test failure. [View commits](https://togithub.com/coleifer/peewee/compare/3.9.0...3.9.2) ### [`v3.9.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#391-and-392) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.9.0...3.9.1) Includes a bugfix for an `AttributeError` that occurs when using MySQL with the `MySQLdb` client. The 3.9.2 release includes fixes for a test failure. [View commits](https://togithub.com/coleifer/peewee/compare/3.9.0...3.9.2) ### [`v3.9.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#390) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.8.2...3.9.0) - Added new document describing how to [use peewee interactively](http://docs.peewee-orm.com/en/latest/peewee/interactive.html). - 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 all `Query` 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 to `Field` - Added `DatabaseProxy`, which allows one to use database-specific decorators with an uninitialized `Proxy` object. See [#1842](https://togithub.com/coleifer/peewee/issues/1842) for discussion. Recommend that you update any usage of `Proxy` for deferring database initialization to use the new `DatabaseProxy` class instead. - Added support for `INSERT ... ON CONFLICT` when the conflict target is a partial index (e.g., contains a `WHERE` clause). The `OnConflict` and `on_conflict()` APIs now take an additional `conflict_where` parameter to represent the `WHERE` clause of the partial index in question. See [#1860](https://togithub.com/coleifer/peewee/issues/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 using `OR` instead of `AND`. See [#391](https://togithub.com/coleifer/peewee/issues/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](http://docs.peewee-orm.com/en/latest/peewee/api.html#SelectQuery.select_from). - Added documentation on using [row values](http://docs.peewee-orm.com/en/latest/peewee/query_operators.html#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](https://togithub.com/coleifer/peewee/issues/1834) for details. - Fixed bug where `TimestampField` would treat zero values as `None` when reading from the database. [View commits](https://togithub.com/coleifer/peewee/compare/3.8.2...3.9.0) ### [`v3.8.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#382) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.8.1...3.8.2) **Backwards-incompatible changes** - The default row-type for `INSERT` queries executed with a non-default `RETURNING` clause has changed from `tuple` to `Model` instances. This makes `INSERT` behavior consistent with `UPDATE` and `DELETE` queries that specify a `RETURNING` clause. To revert back to the old behavior, just append a call to `.tuples()` to your `INSERT ... RETURNING` query. - Removing support for the `table_alias` model `Meta` option. Previously, this attribute could be used to specify a "vanity" alias for a model class in the generated SQL. As a result of some changes to support more robust UPDATE and DELETE queries, supporting this feature will require some re-working. As of the 3.8.0 release, it was broken and resulted in incorrect SQL for UPDATE queries, so now it is removed. **New features** - Added `playhouse.shortcuts.ReconnectMixin`, which can be used to implement automatic reconnect under certain error conditions (notably the MySQL error 2006 - server has gone away). **Bugfixes** - Fix SQL generation bug when using an inline window function in the `ORDER BY` clause of a query. - Fix possible zero-division in user-defined implementation of BM25 ranking algorithm for SQLite full-text search. [View commits](https://togithub.com/coleifer/peewee/compare/3.8.1...3.8.2) ### [`v3.8.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#381) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.8.0...3.8.1) **New features** - Sqlite `SearchField` now supports the `match()` operator, allowing full-text search to be performed on a single column (as opposed to the whole table). **Changes** - Remove minimum passphrase restrictions in SQLCipher integration. **Bugfixes** - Support inheritance of `ManyToManyField` instances. - Ensure operator overloads are invoked when generating filter expressions. - Fix incorrect scoring in Sqlite BM25, BM25f and Lucene ranking algorithms. - Support string field-names in data dictionary when performing an ON CONFLICT ... UPDATE query, which allows field-specific conversions to be applied. References [#1815](https://togithub.com/coleifer/peewee/issues/1815). [View commits](https://togithub.com/coleifer/peewee/compare/3.8.0...3.8.1) ### [`v3.8.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#380) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.7.1...3.8.0) **New features** - Postgres `BinaryJSONField` now supports `has_key()`, `concat()` and `remove()` methods (though remove may require pg10+). - Add `python_value()` method to the SQL-function helper `fn`, to allow specifying a custom function for mapping database values to Python values. **Changes** - Better support for UPDATE ... FROM queries, and more generally, more robust support for UPDATE and RETURNING clauses. This means that the `QualifiedNames` helper is no longer needed for certain types of queries. - The `SqlCipherDatabase` no longer accepts a `kdf_iter` parameter. To configure the various SQLCipher encryption settings, specify the setting values as `pragmas` when initializing the database. - Introspection will now, by default, only strip "\_id" from introspected column names if those columns are foreign-keys. See [#1799](https://togithub.com/coleifer/peewee/issues/1799) for discussion. - Allow `UUIDField` and `BinaryUUIDField` to accept hexadecimal UUID strings as well as raw binary UUID bytestrings (in addition to `UUID` instances, which are already supported). - Allow `ForeignKeyField` to be created without an index. - Allow multiple calls to `cast()` to be chained ([#1795](https://togithub.com/coleifer/peewee/issues/1795)). - Add logic to ensure foreign-key constraint names that exceed 64 characters are truncated using the same logic as is currently in place for long indexes. - `ManyToManyField` supports foreign-keys to fields other than primary-keys. - When linked against SQLite 3.26 or newer, support `SQLITE_CONSTRAINT` to designate invalid queries against virtual tables. - SQL-generation changes to aid in supporting using queries within expressions following the SELECT statement. **Bugfixes** - Fixed bug in `order_by_extend()`, thanks [@nhatHero](https://togithub.com/nhatHero). - Fixed bug where the `DataSet` CSV import/export did not support non-ASCII characters in Python 3.x. - Fixed bug where `model_to_dict` would attempt to traverse explicitly disabled foreign-key backrefs ([#1785](https://togithub.com/coleifer/peewee/issues/1785)). - Fixed bug when attempting to migrate SQLite tables that have a field whose column-name begins with "primary\_". - Fixed bug with inheriting deferred foreign-keys. [View commits](https://togithub.com/coleifer/peewee/compare/3.7.1...3.8.0) ### [`v3.7.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#371) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.7.0...3.7.1) **New features** - Added `table_settings` model `Meta` option, which should be a list of strings specifying additional options for `CREATE TABLE`, which are placed *after* the closing parentheses. - Allow specification of `on_update` and `on_delete` behavior for many-to-many relationships when using `ManyToManyField`. **Bugfixes** - Fixed incorrect SQL generation for Postgresql ON CONFLICT clause when the conflict_target is a named constraint (rather than an index expression). This introduces a new keyword-argument to the `on_conflict()` method: `conflict_constraint`, which is currently only supported by Postgresql. Refs issue [#1737](https://togithub.com/coleifer/peewee/issues/1737). - Fixed incorrect SQL for sub-selects used on the right side of `IN` expressions. Previously the query would be assigned an alias, even though an alias was not needed. - Fixed incorrect SQL generation for Model indexes which contain SQL functions as indexed columns. - Fixed bug in the generation of special queries used to perform operations on SQLite FTS5 virtual tables. - Allow `frozenset` to be correctly parameterized as a list of values. - Allow multi-value INSERT queries to specify `columns` as a list of strings. - Support `CROSS JOIN` for model select queries. [View commits](https://togithub.com/coleifer/peewee/compare/3.7.0...3.7.1) ### [`v3.7.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#370) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.4...3.7.0) **Backwards-incompatible changes** - Pool database `close_all()` method renamed to `close_idle()` to better reflect the actual behavior. - Databases will now raise `InterfaceError` when `connect()` or `close()` are called on an uninitialized, deferred database object. **New features** - Add methods to the migrations extension to support adding and dropping table constraints. - Add [Model.bulk_create()](http://docs.peewee-orm.com/en/latest/peewee/api.html#Model.bulk_create) method for bulk-inserting unsaved model instances. - Add `close_stale()` method to the connection pool to support closing stale connections. - The `FlaskDB` class in `playhouse.flask_utils` now accepts a `model_class` parameter, which can be used to specify a custom base-class for models. **Bugfixes** - Parentheses were not added to subqueries used in function calls with more than one argument. - Fixed bug when attempting to serialize many-to-many fields which were created initially with a `DeferredThroughModel`, see [#1708](https://togithub.com/coleifer/peewee/issues/1708). - Fixed bug when using the Postgres `ArrayField` with an array of `BlobField`. - Allow `Proxy` databases to be used as a context-manager. - Fixed bug where the APSW driver was referring to the SQLite version from the standard library `sqlite3` driver, rather than from `apsw`. - Reflection library attempts to wrap server-side column defaults in quotation marks if the column data-type is text/varchar. - Missing import in migrations library, which would cause errors when attempting to add indexes whose name exceeded 64 chars. - When using the Postgres connection pool, ensure any open/pending transactions are rolled-back when the connection is recycled. - Even *more* changes to the `setup.py` script. In this case I've added a helper function which will reliably determine if the SQLite3 extensions can be built. This follows the approach taken by the Python YAML package. [View commits](https://togithub.com/coleifer/peewee/compare/3.6.4...3.7.0) ### [`v3.6.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#364) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.3...3.6.4) Take a whole new approach, following what `simplejson` does. Allow the `build_ext` command class to fail, and retry without extensions in the event we run into issues building extensions. References [#1676](https://togithub.com/coleifer/peewee/issues/1676). [View commits](https://togithub.com/coleifer/peewee/compare/3.6.3...3.6.4) ### [`v3.6.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#363) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.2...3.6.3) Add check in `setup.py` to determine if a C compiler is available before building C extensions. References [#1676](https://togithub.com/coleifer/peewee/issues/1676). [View commits](https://togithub.com/coleifer/peewee/compare/3.6.2...3.6.3) ### [`v3.6.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#362) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.1...3.6.2) Use `ctypes.util.find_library` to determine if `libsqlite3` is installed. Should fix problems people are encountering installing when SQLite3 is not available. [View commits](https://togithub.com/coleifer/peewee/compare/3.6.1...3.6.2) ### [`v3.6.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#361) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.6.0...3.6.1) Fixed issue with setup script. [View commits](https://togithub.com/coleifer/peewee/compare/3.6.0...3.6.1) ### [`v3.6.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#360) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.5.2...3.6.0) - Support for Python 3.7, including bugfixes related to new StopIteration handling inside of generators. - Support for specifying `ROWS` or `RANGE` window frame types. For more information, see the new [frame type documentation](http://docs.peewee-orm.com/en/latest/peewee/querying.html#frame-types-range-vs-rows). - Add APIs for user-defined window functions if using [pysqlite3](https://togithub.com/coleifer/pysqlite3) and sqlite 3.25.0 or newer. - `TimestampField` now uses 64-bit integer data-type for storage. - Added support to `pwiz` and `playhouse.reflection` to enable generating models from VIEWs. - Added lower-level database API for introspecting VIEWs. - Revamped continuous integration setup for better coverage, including 3.7 and 3.8-dev. - Allow building C extensions even if Cython is not installed, by distributing pre-generated C source files. - Switch to using `setuptools` for packaging. [View commits](https://togithub.com/coleifer/peewee/compare/3.5.2...3.6.0) ### [`v3.5.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#352) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.5.1...3.5.2) - New guide to using [window functions in Peewee](http://docs.peewee-orm.com/en/latest/peewee/querying.html#window-functions). - New and improved table name auto-generation. This feature is not backwards compatible, so it is **disabled by default**. To enable, set `legacy_table_names=False` in your model's `Meta` options. For more details, see [table names](http://docs.peewee-orm.com/en/latest/peewee/models.html#table_names) documentation. - Allow passing single fields/columns to window function `order_by` and `partition_by` arguments. - Support for `FILTER (WHERE...)` clauses with window functions and aggregates. - Added `IdentityField` class suitable for use with Postgres 10's new identity column type. It can be used anywhere `AutoField` or `BigAutoField` was being used previously. - Fixed bug creating indexes on tables that are in attached databases (SQLite). - Fixed obscure bug when using `prefetch()` and `ModelAlias` to populate a back-reference related model. [View commits](https://togithub.com/coleifer/peewee/compare/3.5.1...3.5.2) ### [`v3.5.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#351) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.5.0...3.5.1) **New features** - New documentation for working with [relationships](http://docs.peewee-orm.com/en/latest/peewee/relationships.html) in Peewee. - Improved tests and documentation for MySQL upsert functionality. - Allow `database` parameter to be specified with `ModelSelect.get()` method. For discussion, see [#1620](https://togithub.com/coleifer/peewee/issues/1620). - Add `QualifiedNames` helper to peewee module exports. - Add `temporary=` meta option to support temporary tables. - Allow a `Database` object to be passed to constructor of `DataSet` helper. **Bug fixes** - Fixed edge-case where attempting to alias a field to it's underlying column-name (when different), Peewee would not respect the alias and use the field name instead. See [#1625](https://togithub.com/coleifer/peewee/issues/1625) for details and discussion. - Raise a `ValueError` when joining and aliasing the join to a foreign-key's `object_id_name` descriptor. Should prevent accidentally introducing O(n) queries or silently ignoring data from a joined-instance. - Fixed bug for MySQL when creating a foreign-key to a model which used the `BigAutoField` for it's primary-key. - Fixed bugs in the implementation of user-defined aggregates and extensions with the APSW SQLite driver. - Fixed regression introduced in 3.5.0 which ignored custom Model `__repr__()`. - Fixed regression from 2.x in which inserting from a query using a `SQL()` was no longer working. Refs [#1645](https://togithub.com/coleifer/peewee/issues/1645). [View commits](https://togithub.com/coleifer/peewee/compare/3.5.0...3.5.1) ### [`v3.5.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#350) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.4.0...3.5.0) **Backwards-incompatible changes** - Custom Model `repr` no longer use the convention of overriding `__unicode__`, and now use `__str__`. - Redesigned the [sqlite json1 integration](http://docs.peewee-orm.com/en/latest/peewee/sqlite_ext.html#sqlite-json1). and changed some of the APIs and semantics of various `JSONField` methods. The documentation has been expanded to include more examples and the API has been simplified to make it easier to work with. These changes **do not** have any effect on the [Postgresql JSON fields](http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#pgjson). **New features** - Better default `repr` for model classes and fields. - `ForeignKeyField()` accepts a new initialization parameter, `deferrable`, for specifying when constraints should be enforced. - `BitField.flag()` can be called without a value parameter for the common use-case of using flags that are powers-of-2. - `SqliteDatabase` pragmas can be specified as a `dict` (previously required a list of 2-tuples). - SQLite `TableFunction` ([docs](http://docs.peewee-orm.com/en/latest/peewee/sqlite_ext.html#sqlite-vtfunc)) will print Python exception tracebacks raised in the `initialize` and `iterate` callbacks, making debugging significantly easier. **Bug fixes** - Fixed bug in `migrator.add_column()` where, if the field being added declared a non-standard index type (e.g., binary json field with GIN index), this index type was not being respected. - Fixed bug in `database.table_exists()` where the implementation did not match the documentation. Implementation has been updated to match the documentation. - Fixed bug in SQLite `TableFunction` implementation which raised errors if the return value of the `iterate()` method was not a `tuple`. [View commits](https://togithub.com/coleifer/peewee/compare/3.4.0...3.5.0) ### [`v3.4.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#340) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.4...3.4.0) **Backwards-incompatible changes** - The `regexp()` operation is now case-sensitive for MySQL and Postgres. To perform case-insensitive regexp operations, use `iregexp()`. - The SQLite `BareField()` field-type now supports all column constraints *except* specifying the data-type. Previously it silently ignored any column constraints. - LIMIT and OFFSET parameters are now treated as parameterized values instead of literals. - The `schema` parameter for SQLite database introspection methods is no longer ignored by default. The schema corresponds to the name given to an attached database. - `ArrayField` now accepts a new parameter `field_kwargs`, which is used to pass information to the array field's `field_class` initializer. **New features and other changes** - SQLite backup interface supports specifying page-counts and a user-defined progress handler. - GIL is released when doing backups or during SQLite busy timeouts (when using the peewee SQLite busy-handler). - Add NATURAL join-type to the `JOIN` helper. - Improved identifier quoting to allow specifying distinct open/close-quote characters. Enables adding support for MSSQL, for instance, which uses square brackets, e.g. `[table].[column]`. - Unify timeout interfaces for SQLite databases (use seconds everywhere rather than mixing seconds and milliseconds, which was confusing). - Added `attach()` and `detach()` methods to SQLite database, making it possible to attach additional databases (e.g. an in-memory cache db). [View commits](https://togithub.com/coleifer/peewee/compare/3.3.4...3.4.0) ### [`v3.3.4`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#334) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.3...3.3.4) - Added a `BinaryUUIDField` class for efficiently storing UUIDs in 16-bytes. - Fix dataset's `update_cache()` logic so that when updating a single table that was newly-added, we also ensure that all dependent tables are updated at the same time. Refs [coleifer/sqlite-web#42](https://togithub.com/coleifer/sqlite-web/issues/42). [View commits](https://togithub.com/coleifer/peewee/compare/3.3.3...3.3.4) ### [`v3.3.3`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#333) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.2...3.3.3) - More efficient implementation of model dependency-graph generation. Improves performance of recursively deleting related objects by omitting unnecessary subqueries. - Added `union()`, `union_all()`, `intersect()` and `except_()` to the `Model`-specific query implementations. This was an oversight that should have been patched in 3.3.2, but is fixed in 3.3.3. - Major cleanup to test runner and standardized test skipping logic to integrate with standard-library `unittest` conventions. [View commits](https://togithub.com/coleifer/peewee/compare/3.3.2...3.3.3) ### [`v3.3.2`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#332) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.1...3.3.2) - Add methods for `union()`, `union_all`, `intersect()` and `except_()`. Previously, these methods were only available as operator overloads. - Removed some Python 2.6-specific support code, as 2.6 is no longer officially supported. - Fixed model-graph resolution logic for deferred foreign-keys. - Better support for UPDATE...FROM queries (Postgresql). [View commits](https://togithub.com/coleifer/peewee/compare/3.3.1...3.3.2) ### [`v3.3.1`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#331) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.3.0...3.3.1) - Fixed long-standing bug in 3.x regarding using column aliases with queries that utilize the ModelCursorWrapper (typically queries with one or more joins). - Fix typo in model metadata code, thanks [@klen](https://togithub.com/klen). - Add examples of using recursive CTEs to docs. [View commits](https://togithub.com/coleifer/peewee/compare/3.3.0...3.3.1) ### [`v3.3.0`](https://togithub.com/coleifer/peewee/blob/HEAD/CHANGELOG.md#330) [Compare Source](https://togithub.com/coleifer/peewee/compare/3.2.5...3.3.0) - Added support for SQLite's new `ON CONFLICT` clause, which is modelled on the syntax used by Postgresql and will be available in SQLite 3.24.0 and onward. - Added better support for using common table expressions and a cleaner way of implementing recursive CTEs, both of which are also tested with integration tests (as opposed to just checking theConfiguration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.