oso 0.8.0

Breaking changes


This release contains breaking changes. Be sure to follow migration steps before upgrading.

Explicit iterator syntax

Calling methods and accessing attributes on application instances no longer returns multiple values. Instead, to iterate over values of an application instance the explicit in operator must be used.

Old syntax:

amount = recipe.ingredients().quantity

New syntax:

item in recipe.ingredients() and
amount = item.quantity

With this change, any methods on the iterable instance itself can now be used:


The above would call the total_cost method on the iterable returned by recipe.ingredients().

New features


Polar now defines a constant named nil, whose value is an application-language specific “null” value; e.g., None in Python, nil in Ruby, null for Java & JS, etc. Explicit comparisons with nil are particularly useful in the context of application-language methods that may return None, etc.

In the (still preview) context of list filtering via partial evaluation, nil is intended to map to NULL in SQL. For instance, partially evaluating the Polar expression x = nil with respect to x yields a constraint that is translated into a check like X IS NULL.

Other bugs & improvements

  • List filtering now supports queries involving inversion (the not operator) properly.

  • Polar now checks fields in the case of a matches against a built-in language type. E.g.:

    2 matches Integer { numerator: 2, denominator: 1 }
  • More invalid expressions are captured at parse time. For example, you cannot perform arithmetic over logical operations, (x = 1) + (x = 2), nor can you check an arithmetic expression for “truthiness”, i.e. 1 or 2 will also fail to parse:

    query> (x = 1) + (x = 2)
    Wrong value type: x = 1. Expected a value at line 1, column 1
    query> 1 or 2
    Wrong value type: 1. Expected a logical at line 1, column 1
  • Matching an unbound variable against a pattern now results in an error. Previously this would bind the variable with the pattern, resulting in unexpected behavior. For example:

    query> x matches String
    trace (most recent evaluation last):
      in query at line 1, column 1
        x matches String
    Type error: cannot bind pattern 'String' to 'x' at line 1, column 11


    query> "abc" matches String

django-oso 0.4.0

Bumped the minimum required version of the oso dependency.

flask-oso 0.5.0

Bumped the minimum required version of the oso dependency.

Connect with us on Slack

If you have any questions, or just want to talk something through, jump into Slack. An Oso engineer or one of the thousands of developers in the growing community will be happy to help.