Changelog¶
1.0.0b5¶
- Added official support for Python 3.9.
- BREAKING CHANGE: Renamed the term
TransactiontoSession, 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
Sessioncontext managers. When in a context, newly instantiated models will be automatically added to the session. At the end of the context, acommitwill be automatically triggered, as well asrollbackwhen exceptions are thrown. Please see Context Manager for details.
1.0.0b4¶
- Added new field types
FloatField,UUIDFieldandEnumField. - Added
type_checkflag toFieldto 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.setterdecorator in models. - Added support for the built-in python
@propertyin models. - Added support for customizable
Metanested class in models, which now supports modifying the two new attributesinitandinit_ignore_extra. - Added
BaseModelconstructor 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 newMetaattributerepr = False, or on field level with the parameterrepr=False. On both levels, the parameters default toTrue. - 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 aSetinstead of aList. This also applies to the input argumentchildren. - 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 aTransactionExceptionwith all thetasksthat failed and all that succeeded during aTransaction.commit(). - BREAKING CHANGE: Changed the behavior of
Transaction.commit()to automatically callTransaction.raise_for_status()wheneverraise_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
restiomodule anymore. You will now need to import from the submodules directly (e.g. what used to befrom restio import BaseModelshould now befrom 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
BaseModelhas been refactored to supportField. 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:PrimaryKeyandValueKeyhave been removed, in favor ofField(pk=True).mdataclasshas been removed.BaseModel.pre_setup_modelandBaseModel.post_setup_modelhave been removed.- Model dependencies are now tracked via fields with
depends_on=True. BaseModel.get_keys()method has been replaced for the propertyBaseModel.primary_keys, which now returns a dictionary.- A new model state
UNBOUNDhas been introduced. All new instances of a model will by default have this state until it is added to a transaction.
BaseDAOnow contains an internal attributetransactionof typeTransaction. This field will always contain the instance of the transaction to which the DAO instance is bound.Transaction.getnow requires keyword-only arguments to be provided when passing primary keys. Calls with missing primary keys will fail immediately.Transaction.getwill no longer returnNonewhen no models are found by the DAO or in the cache. Instead, aRuntimeErrorwill be raised.Transaction.getandTransaction.querywill no longer automatically register model dependencies (children). This is done to encourage the use of theTransactionfrom within the DAOs or queries when retrieving multiple models at the same time.In queries, the use of the
selfkeyword (that received the injectedTransactioninstance) has been replaced by an optional keyword-only argumenttransaction.Transaction.querywill now always returntupleas 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 thetuplereturned byTransaction.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
mutableattributes/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>