Changelog

1.0.0b5

  • Added official support for Python 3.9.
  • BREAKING CHANGE: Renamed the term Transaction to Session, so that the naming is more consistent with the intent. As per community feedback, the term Transaction would often imply that rollbacks are possible on server side, as it happens in other database ORMs. This change applies to modules, classes, variables and all other references.
  • To follow the above change, an improved description of Session.rollback() has been added.
  • Added support for Session context managers. When in a context, newly instantiated models will be automatically added to the session. At the end of the context, a commit will be automatically triggered, as well as rollback when exceptions are thrown. Please see Context Manager for details.

1.0.0b4

  • Added new field types FloatField, UUIDField and EnumField.
  • Added type_check flag to Field to allow disabling runtime type-checking for the field. All fields will still have type-checking enabled by default (type_check=True), making this a backwards-compatible change.

1.0.0b3

  • Added support for Field Setters with the Field.setter decorator in models.
  • Added support for the built-in python @property in models.
  • Added support for customizable Meta nested class in models, which now supports modifying the two new attributes init and init_ignore_extra.
  • Added BaseModel constructor that collects parameters and assigns them to fields automatically by name.
  • Added BaseModel.__repr__ which returns the string representation of models. This can be disabled on a model class level with a new Meta attribute repr = False, or on field level with the parameter repr=False. On both levels, the parameters default to True.
  • Improved performance when registering objects to the transaction cache. Registering a new object to a transaction that already contains many models registered will now be faster. Also, applies when queries retrieve multiple objects at once.
  • BREAKING CHANGE: BaseModel.get_children() now returns a Set instead of a List. This also applies to the input argument children.
  • BREAKING CHANGE: Native fields no longer contain pre-defined default values. Fields without default now are required to be set as part of the constructor of the model, which will raise and Exception otherwise.

1.0.0b2

  • Fixed bug that failed to properly check trees of models with deleted state.
  • Fixed bug that would maintain an incorrect persistent state of models when a model was unbound from a transaction.
  • Added restriction in which it is not possible anymore to register a model after it has been discarded. Also, during a Transaction.reset() all models are now marked as discarded.
  • Added check that rejects model attribute updates when the provided values depend on models that are not yet in the transaction cache.
  • Added a static method Transaction.raise_for_status(tasks) that raises a TransactionException with all the tasks that failed and all that succeeded during a Transaction.commit().
  • BREAKING CHANGE: Changed the behavior of Transaction.commit() to automatically call Transaction.raise_for_status() whenever raise_for_status=True (default).

1.0.0b1

Warning

Several important breaking changes were introduced in this version.

  • Main modules cannot be imported directly from top-level restio module anymore. You will now need to import from the submodules directly (e.g. what used to be from restio import BaseModel should now be from restio.model import BaseModel, and so on).

  • Added support for descriptors using the base type Field (restio.fields.Field). The following types of Fields are natively available (please visit Fields for all details):

    • IntField
    • StrField
    • BoolField
    • TupleField
    • FrozenSetField
    • ModelField
    • TupleModelField
    • FrozenSetModelField
  • Behavior of BaseModel has been refactored to support Field. The side effect is that dataclasses are no longer supported, and classes should use the descriptor protocol to define fields that must be tracked by restio. As part of that:

    • PrimaryKey and ValueKey have been removed, in favor of Field(pk=True).
    • mdataclass has been removed.
    • BaseModel.pre_setup_model and BaseModel.post_setup_model have been removed.
    • Model dependencies are now tracked via fields with depends_on=True.
    • BaseModel.get_keys() method has been replaced for the property BaseModel.primary_keys, which now returns a dictionary.
    • A new model state UNBOUND has been introduced. All new instances of a model will by default have this state until it is added to a transaction.
  • BaseDAO now contains an internal attribute transaction of type Transaction. This field will always contain the instance of the transaction to which the DAO instance is bound.

  • Transaction.get now requires keyword-only arguments to be provided when passing primary keys. Calls with missing primary keys will fail immediately.

  • Transaction.get will no longer return None when no models are found by the DAO or in the cache. Instead, a RuntimeError will be raised.

  • Transaction.get and Transaction.query will no longer automatically register model dependencies (children). This is done to encourage the use of the Transaction from within the DAOs or queries when retrieving multiple models at the same time.

  • In queries, the use of the self keyword (that received the injected Transaction instance) has been replaced by an optional keyword-only argument transaction.

  • Transaction.query will now always return tuple as a result, regardless of the return type of the query.

  • @query-annotated functions should now return any Iterable type. The order of the results is preserved in the tuple returned by Transaction.query.

  • Type-hinting should now work better than before.

  • The old concept of mutability (indicating if a field can change or not within the premises of restio) has been droped from the framework. From now on, when we refer to mutable attributes/fields we literally mean the general concept of mutability.

  • Documentation have been completely refactored to include latest changes and more practical examples. The old examples have been removed.

  • A number of bugs have been fixed.

0.3.0 & older

<not available>