[PonyORM-list] Pony ORM Release 0.6.5

Alexey Malashkevich alexeymalashkevich at gmail.com
Mon Apr 4 12:34:59 UTC 2016

Hi all,

This release contains a number of bug fixes and one enhancement -
of the prefetch() method.

Fixed #168: Incorrect caching when slicing the same query multiple times
The bug appeared when the same query instance was sliced more than once.

The result of first slicing was cached and used for all subsequent slices.
The correct behavior is to generate new SQL query with different
LIMIT…OFFSET parameters.

Fixed #169: When py_check() returns False, Pony should truncate too large
values in resulting ValueError message

Before this fix, when you tried to assign a long str or bytes value and if
didn’t pass the validation, the whole string was printed in the stacktrace.
That could be inconvenient if the string was pretty long. Now we show only
first 100 symbols and truncate the rest.

Fixed #171: AssertionError when saving changes of multiple objects

The bug appeared when there was a one-to-one relationship between two
and both ends of this relationship were declared as Optional. When you
to create objects and link them in the same transaction, it could cause the
AssertionError: _save_() called for object ... with incorrect status

Fixed #172: Query prefetch() method should load specified lazy attributes
right in the main query if possible

Before this release, the result of prefetch() method on a lazy attribute
a separate SQL query. That’s because the goal was not in minimizing SQL
queries, but in loading all necessary data before leaving the db_session
Now Pony does prefetch smarter – it tries to minimize the number of SQL

Let’s consider an example:

    from pony.orm import *

    db = Database()

    class Post(db.Entity):
        title = Required(str, 128)
        text = Required(LongStr)

    db.bind('sqlite', ':memory:')

    with db_session:
        posts = Post.select().prefetch(Post.text)[:]

In this example the text attribute is declared as the lazy string type.
Before this
release Pony always loaded lazy attributes using a separate SQL query. Now,
if you pass such a lazy attribute to the prefetch() method, Pony will
this field in the main SQL query:

    SELECT "p"."id", "p"."title", "p"."text"
    FROM "Post" "p"

Fixed #176: Autostripped strings are not validated correctly for Required

The bug was that Pony automatically striped attribute value after
not before it. So, if we had a Required attribute and tried to assign some
value which contained only spaces, Pony would through the
ValueError: Attribute ... is required.
Now Pony first strips the value and then does the validation.

To install the updated version use the following command:

pip install --upgrade pony

Pony ORM Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20160404/e14ffdf1/attachment.html>

More information about the ponyorm-list mailing list