Releases: coleifer/peewee
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()
andexcept_()
to theModel
-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.
3.3.2
- Add methods for
union()
,union_all
,intersect()
andexcept_()
. 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).
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). If you're using an ancient version of SQLite (3.8 or older) you may need to manually add
.alias('column_name')
to selected fields if you find that the values are unexpectedly empty after upgrading. - Fix typo in model metadata code, thanks @klen.
- Add examples of using recursive CTEs to docs.
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 generated SQL).
- Modernized the CI environment to utilize the latest MariaDB features, so we can test window functions and CTEs with MySQL (when available).
- Reorganized and unified the feature-flags in the test suite.
3.2.5
3.2.4
- Smarter handling of model-graph when dealing with compound queries (union, intersect, etc). #1579.
- If the same column-name is selected multiple times, first value wins. #1579.
- If
ModelSelect.switch()
is called without any arguments, default to the query's model. Refs #1573. - Fix issue where cloning a ModelSelect query did not result in the joins being cloned. #1576.
3.2.3
pwiz
tool will capture column defaults defined as part of the table schema.- Fixed a misleading error message - #1563.
- Ensure
reuse_if_open
parameter has effect on pooled databases. - Added support for on update/delete when migrating foreign-key.
- Fixed bug in SQL generation for subqueries in aliased functions #1572.
3.2.2
- Added support for passing
Model
classes to thereturning()
method when
you intend to return all columns for the given model. - Fixed a bug when using user-defined sequences, and the underlying sequence
already exists. - Added
drop_sequences
parameter todrop_table()
method which allows you to
conditionally drop any user-defined sequences when dropping the table.
3.2.1
Notice: the default mysql driver for Peewee has changed to pymysql
in version 3.2.1. In previous versions, if both mysql-python and pymysql
were installed, Peewee would use mysql-python. As of 3.2.1, if both libraries
are installed Peewee will use pymysql.
- Added new module
playhouse.mysql_ext
which includesMySQLConnectorDatabase
, a database implementation that works with the mysql-connector driver. - Added new field to
ColumnMetadata
class which captures a database column's default value.ColumnMetadata
is returned byDatabase.get_columns()
. - Added documentation on making Peewee async.
3.2.0
The 3.2.0 release introduces a potentially backwards-incompatible change. The
only users affected will be those that have implemented custom Field
types
with a user-defined coerce
method. tl/dr: rename the coerce attribute to
adapt and you should be set.
Field.coerce renamed to Field.adapt
The Field.coerce
method has been renamed to Field.adapt
. The purpose of
this method is to convert a value from the application/database into the
appropriate Python data-type. For instance, IntegerField.adapt
is simply the
int
built-in function.
The motivation for this change is to support adding metadata to any AST node
instructing Peewee to not coerce the associated value. As an example, consider
this code:
class Note(Model):
id = AutoField() # autoincrementing integer primary key.
content = TextField()
# Query notes table and cast the "id" to a string and store as "id_text" attr.
query = Note.select(Note.id.cast('TEXT').alias('id_text'), Note.content)
a_note = query.get()
print((a_note.id_text, a_note.content))
# Prior to 3.2.0 the CAST is "un-done" because the value gets converted
# back to an integer, since the value is associated with the Note.id field:
(1, u'some note') # 3.1.7, e.g. -- "id_text" is an integer!
# As of 3.2.0, CAST will automatically prevent the conversion of field values,
# which is an extension of a more general metadata API that can instruct Peewee
# not to convert certain values.
(u'1', u'some note') # 3.2.0 -- "id_text" is a string as expected.
If you have implemented custom Field
classes and are using coerce
to
enforce a particular data-type, you can simply rename the attribute to adapt
.
Other changes
Old versions of SQLite do not strip quotation marks from aliased column names
in compound queries (e.g. UNION). Fixed in 3.2.0.