<div dir="ltr"><div><div>Hi all,<br><br></div><div>We are moving forward to the Pony ORM 0.5 Release and today we've<br></div><div>prepared the release candidate which includes several bug fixes and <br>a couple of new features. You can obtain the update at our github page<br>
<a href="https://github.com/ponyorm/pony">https://github.com/ponyorm/pony</a><br></div><div>Please let us know if you have any issues with it.<br></div><div><br></div><div>Below is the list of updates:<br></div><div><br>- Before this release Pony used the exact letter case of an entity for <br>
the MySQL database table names (unless you specify the table name <br>explicitly using the _table_ option).<br>This approach turned out to be not reliable on all platforms: “MySQL <br>table names are case-sensitive depending on the filesystem of the server. <br>
Since Windows and Mac are a case-insensitive OS, and Linux is case-sensitive; <br>the MySQL database treats the uppercase table name differently than <br>lowercase table name on Linux machines.”<br><br>The official MySQL documentation reads:<br>
To avoid problems caused by such differences, it is best to adopt a <br>consistent convention, such as always creating and referring to databases <br>and tables using lowercase names. This convention is recommended for <br>
maximum portability and ease of use. Following this recommendation, <br>starting with this release, Pony converts all the table names during its <br>creation in accordance with the style of the respective database system. <br>
In MySQL and PostgreSQL Pony converts the table names to the lower case. <br>In Oracle – to the upper case. In SQLite there is no need to convert the <br>letter case – SQLite works with the table name letter case equally on all <br>
platforms.In order to make the new release compatible with your tables <br>created with the previous Pony releases you have a couple of options:<br><br>Specify the table names for each entity explicitly:<br><br>    class MyEntity(db.Entity):<br>
        _table_ = "MyEnity"<br>        ...<br>        <br>Convert the names of your tables to the lower case using SQL commands manually:<br><br>    RENAME TABLE `MyEntity` TO `myentity`<br>    <br>- Starting with this release the names of tables, indexes and constraints <br>
in the database creation script are sorted in the alphabetical order.<br>Now you can use lambdas instead of parenthesis for the entities which are <br>declared later in your code:<br><br>    class User(db.Entity):<br>        name = Required(unicode)<br>
        photos = Set(lambda: Photo)<br><br>    class Photo(db.Entity):<br>        content = Required(buffer)<br>        user = Required(User)<br>        <br>This can be useful if you want your IDE to check the names of declared <br>
entities and highlight typos.<br><br>- Instances now have the before_insert, before_update, before_delete hooks:<br>    class MyEntity(db.Entity):<br>        ...<br>        def before_insert(self):<br>            print '%s is about to be inserted!' % self<br>
        def before_update(self):<br>            print '%s is about to be updated!' % self<br>        def before_delete(self):<br>            print '%s is about to be deleted!' % self<br>            <br>- Now options.MAX_FETCH_COUNT is set to None by default. Before this release <br>
Pony would throw the TooManyRowsFound exception if the number of instances <br>returned by a query exceeds the MAX_FETCH_COUNT. Since this parameter <br>can vary greatly, Pony doesn’t set it by default anymore.<br><br>- We have added the concat() function and now you can do the following:<br>
    <br>select(concat(<a href="http://s.name">s.name</a>, ':', s.dob.year, ':', s.scholarship) for s in Student)<br><br>- With the new Pony release you have the read-only access to the entity <br>instances outside of the db_session. Before this release any attempt <br>
to use an instance outside of the db_session would result in a <br>TransactionRolledBack exception. Now you can get the attribute values, <br>but if the attribute that you’re trying to access was not loaded, then <br>you’ll get the DatabaseSessionIsOver exception. The same exception will <br>
be raised in case you want to change attribute values.<br>We hope that this option will not be misused. Most of the time you want <br>to use entity instances within the db_session. If you find yourself using <br>the instances outside of the db_session often, you probably doing something <br>
strange.<br><br>- Now when you create new instances you can use the value of the primary key <br>instead of the object. This is how you created an instance of a Student before:<br><br>    student = Student(name='Student name', group=Group[123])<br>
    <br>and now you can pass a primary key of the Group object instead:<br><br>    student = Student(name='Student name', group=123)<br>    <br>The same approach can be used for the get() method.<br><br>- Now you can specify the sequence name for PrimaryKey attributes for Oracle <br>
databases using the keyword argument sequence_name=’seq_name’<br><br>- The bug #41 was fixed. Now you can use the same variable name in subsequent <br>filters and it can have different values.<br><br>- Numerous other bugs were fixed.<br>
<br></div><div>You can get the latest update from <a href="https://github.com/ponyorm/pony">https://github.com/ponyorm/pony</a><br></div><div><br></div>Regards,<br></div>Alexey Malashkevich<br></div>