<div dir="ltr"><div><div>Hi all,</div><div><br></div><div>This release contains a number of bug fixes and one enhancement - optimization</div><div>of the prefetch() method.</div><div><br></div><div><br></div><div>Fixed #168: Incorrect caching when slicing the same query multiple times </div><div>The bug appeared when the same query instance was sliced more than once. </div><div><br></div><div>The result of first slicing was cached and used for all subsequent slices. </div><div>The correct behavior is to generate new SQL query with different </div><div>LIMIT…OFFSET parameters.</div><div><br></div><div><br></div><div>Fixed #169: When py_check() returns False, Pony should truncate too large </div><div>values in resulting ValueError message</div><div><br></div><div>Before this fix, when you tried to assign a long str or bytes value and if </div><div>didn’t pass the validation, the whole string was printed in the stacktrace. </div><div>That could be inconvenient if the string was pretty long. Now we show only </div><div>first 100 symbols and truncate the rest.</div><div><br></div><div><br></div><div>Fixed #171: AssertionError when saving changes of multiple objects</div><div><br></div><div>The bug appeared when there was a one-to-one relationship between two entities </div><div>and both ends of this relationship were declared as Optional. When you tried </div><div>to create objects and link them in the same transaction, it could cause the </div><div>AssertionError: _save_() called for object ... with incorrect status 'inserted'</div><div><br></div><div><br></div><div>Fixed #172: Query prefetch() method should load specified lazy attributes </div><div>right in the main query if possible</div><div><br></div><div>Before this release, the result of prefetch() method on a lazy attribute was </div><div>a separate SQL query. That’s because the goal was not in minimizing SQL </div><div>queries, but in loading all necessary data before leaving the db_session scope. </div><div>Now Pony does prefetch smarter – it tries to minimize the number of SQL queries.</div><div><br></div><div>Let’s consider an example:</div><div><br></div><div>    from pony.orm import *</div><div><br></div><div>    db = Database()</div><div><br></div><div>    class Post(db.Entity):</div><div>        title = Required(str, 128)</div><div>        text = Required(LongStr)</div><div><br></div><div>    db.bind('sqlite', ':memory:')</div><div>    db.generate_mapping(create_tables=True)</div><div>    sql_debug(True)</div><div><br></div><div>    with db_session:</div><div>        posts = Post.select().prefetch(Post.text)[:]</div><div><br></div><div>In this example the text attribute is declared as the lazy string type. Before this </div><div>release Pony always loaded lazy attributes using a separate SQL query. Now, </div><div>if you pass such a lazy attribute to the prefetch() method, Pony will retrieve </div><div>this field in the main SQL query:</div><div><br></div><div>    SELECT "p"."id", "p"."title", "p"."text"</div><div>    FROM "Post" "p"</div><div><br></div><div><br></div><div>Fixed #176: Autostripped strings are not validated correctly for Required </div><div>attributes</div><div><br></div><div>The bug was that Pony automatically striped attribute value after validation, </div><div>not before it. So, if we had a Required attribute and tried to assign some </div><div>value which contained only spaces, Pony would through the </div><div>ValueError: Attribute ... is required. </div><div>Now Pony first strips the value and then does the validation.</div><div><br></div><div><br></div><div>To install the updated version use the following command:</div><div><br></div><div>pip install --upgrade pony</div><div><br></div><div>Best,</div><div>Pony ORM Team</div></div><div><br></div></div>