Pony ORM Release 0.7.6

In release 0.7.4 we introduced support of hybrid methods and properties. This change required massive refactoring which lead to some bugs. Current release fixes all new bugs revealed after 0.7.4.

Also in this release some nice features were added. The first is the support of Literal String Interpolation a.k.a f-strings, introduced in Python 3.6. It looks nicely than using of %-interpolation or format method. f-strings use two special bytecode instructions which Pony now able to decompile and translate correctly:

select(f'The age of {s.name} is {s.age}' for s in Student)

The second small feature is a possibility to skip initial rows in query by specifying offset without limit. In order to do this, you can pass None as a limit value, or just omit limit value at all.

Also now it is possible to explicitly case JSON expressions to int, str or float. It may be necessary if you want to mix JSON expressions with expressions of other types in functions like coalesce()

Finally, we introduced @db.on_connect decorator which can be used to set up some connection properties. For example, since release 0.7.4 like in SQLite works as case-sensitive for better compatibility with other database management systems. If for some reason you want to restore the old like behavior, you can set corresponding pragma on SQLite connection:

@db.on_connect(provider='sqlite')
def set_case_insensitive_like(db, connection):
    cursor = connection.cursor()
    cursor.execute('PRAGMA case_sensitive_like = OFF')

Below is the full changelog since 0.7.5:

Features

  • f-strings support in queries select(f'{s.name} - {s.age}' for s in Student)
  • #344: It is now possible to specify offset without limit: query.limit(offset=10)
  • #371: Support of explicit casting of JSON expressions to str, int or float
  • @db.on_connect decorator added

Bugfixes

  • Fix bulk delete bug introduced in 0.7.4
  • #370 Fix memory leak introduced in 0.7.4
  • Now exists() in query does not throw away condition in generator expression: exists(s.gpa > 3 for s in Student)
  • #373: 0.7.4/0.7.5 breaks queries using the in operator to test membership of another query result
  • #374: auto=True can be used with all PrimaryKey types, not only int
  • #369: Make QueryResult looks like a list object again: add concatenation with lists, .shuffle() and .to_list() methods
  • #355: Fix binary primary keys PrimaryKey(buffer) in Python2
  • Interactive mode support for PyCharm console
  • Fix wrong table aliases in complex queries
  • Fix query optimization code for complex queries
  • Fix a bug with hybrid properties that use external functions