Changes in 0.2 ============== 0.2.0 ~~~~~ - Added ability to export :py:mod:`hiku.query` nodes. Added :py:mod:`hiku.export.simple` exporter, which will export query into EDN data structure - Added debug mode for the :py:mod:`hiku.console` application, showing Python tracebacks if debug mode is turned on - Implemented :py:class:`hiku.validate.query.QueryValidator` to validate query against graph definition before it's execution - Implemented :py:class:`hiku.validate.graph.GraphValidator` to validate graph definition - Added ability to define graph links with :py:const:`hiku.types.Optional` type: .. code-block:: python Link('link-to-foo', Optional[TypeRef['foo']], func, requires=None) - Added ability to query complex fields, which has a type of ``Optional[Record[...]]``, ``Record[...]`` or ``Sequence[Record[...]]`` as if they were linked edges: .. code-block:: python Edge('foo', [ Field('bar', Record[{'baz': Integer}], func), ]) Here ``bar`` field should be queried as it was a link to the edge: .. code-block:: clojure [{:link-to-foo [{:bar [:baz]}]}] - Added ability to use scalar values in the expressions. Currently only integer numbers and strings are supported: .. code-block:: python Expr('foo', foo_subgraph, func(S.this.foo, 'scalar')) - Implemented :py:func:`hiku.expr.if_some` function in order to unpack :py:class:`hiku.types.Optional` type in expressions - Added ability to pass objects, required to execute query, using bound to the query context: .. code-block:: python @pass_context def func(ctx, fields): return [ctx['storage'][f.name] for f in fields] Root([ Field('foo', None, func), ]) engine.execute(graph, read('[:foo]'), ctx={'storage': {'foo': 1}}) - Implemented new :py:mod:`hiku.sources.aiopg` source for using aiopg_ and :py:class:`hiku.executors.asyncio.AsyncIOExecutor` to asynchronously load data from the `PostgreSQL` database - Added ability to define function arguments using types instead of queries: .. code-block:: python @define(Record[{'foo': Integer}]) # instead of @define('[[:foo]]') def func(arg): return arg['foo'] + 1 Backward-incompatible changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Changed type of :py:attr:`hiku.graph.Field.options` from ``Mapping[str, Option]`` to ``Sequence[Option]`` - Changed type of :py:attr:`hiku.graph.Link.options` from ``Mapping[str, Option]`` to ``Sequence[Option]`` - Changed type of :py:attr:`hiku.graph.Edge.fields` from ``Mapping[str, Union[Field, Link]]`` to ``Sequence[Union[Field, Link]]`` - Changed type of :py:attr:`hiku.query.Edge.fields` from ``Mapping[str, Union[Field, Link]]`` to ``Sequence[Union[Field, Link]]`` - :py:class:`hiku.graph.Graph` is not a subclass of the :py:class:`hiku.graph.Edge` anymore, all the root edges, fields and links should be defined in the :py:class:`hiku.graph.Root` edge. Now :py:class:`hiku.graph.Graph` can contain only edges - All :py:mod:`hiku.types` and :py:mod:`hiku.typedef.types` are now subclasses of ``type``, instead of being instances of ``type`` - Renamed :py:class:`hiku.types.Type` into :py:class:`hiku.types.GenericMeta` - Renamed :py:class:`hiku.types.BooleanType` into :py:class:`hiku.types.Boolean` - Renamed :py:class:`hiku.types.StringType` into :py:class:`hiku.types.String` - Renamed :py:class:`hiku.types.IntegerType` into :py:class:`hiku.types.Integer` - Renamed :py:class:`hiku.types.OptionType` into :py:class:`hiku.types.Optional` - Renamed :py:class:`hiku.types.ListType` into :py:class:`hiku.types.Sequence` - Renamed :py:class:`hiku.types.DictType` into :py:class:`hiku.types.Mapping` - Renamed :py:class:`hiku.types.RecordType` into :py:class:`hiku.types.Record` - Renamed :py:class:`hiku.types.FunctionType` into :py:class:`hiku.types.Callable` - Removed :py:class:`hiku.types.ContainerType` - Removed :py:func:`hiku.types.to_instance` - Moved :py:class:`hiku.typedef.types.TypeRef` into :py:class:`hiku.types.TypeRef` - Moved :py:class:`hiku.typedef.types.TypeRefMeta` into :py:class:`hiku.types.TypeRefMeta` - Replaced required keyword arguments ``to_list`` and ``edge`` in the :py:class:`hiku.graph.Link` class by one second positional argument, which can have one of these values: - ``TypeRef['foo']`` or ``Optional[TypeRef['foo']]`` instead of ``edge='foo', to_list=False`` - ``Sequence[TypeRef['foo']]`` instead of ``edge='foo', to_list=True`` Before: .. code-block:: python Link('foo', func, edge='bar', requires='id', to_list=True) Now: .. code-block:: python Link('foo', Sequence[TypeRef['bar']], func, requires='id') - Replaced required keyword arguments ``to_list`` and ``edge`` in the :py:class:`hiku.sources.sqlalchemy.LinkQuery` class by one second positional argument, as in :py:class:`hiku.graph.Link` - Renamed required keyword argument and corresponding instance attribute from ``doc`` into ``description`` in the :py:class:`hiku.graph.Field`, :py:class:`hiku.graph.Link`, :py:class:`hiku.graph.Edge` and in the :py:class:`hiku.sources.sqlalchemy.Link` classes - Renamed attribute of the :py:class:`hiku.typedef.kinko.TypeDoc` from ``__type_doc__`` into ``__type_description__`` - Moved constant :py:const:`hiku.engine.Nothing` to the :py:const:`hiku.graph.Nothing` - Renamed attribute :py:attr:`hiku.result.Ref.storage` into :py:attr:`hiku.result.Ref.index` - Renamed attribute :py:class:`hiku.result.State.idx` into :py:class:`hiku.result.State.index` - :py:class:`hiku.sources.sqlalchemy.FieldsQuery` and :py:class:`hiku.sources.sqlalchemy.LinkQuery` now require context keys instead of "connectable" objects (SQLAlchemy's scoped session) - Moved type :py:class:`hiku.typedef.types.Unknown` to the :py:class:`hiku.types.Unknown` - Positional ``type`` argument in :py:class:`hiku.graph.Field` and in :py:class:`hiku.graph.Option` now is required .. _aiopg: https://aiopg.readthedocs.io/