Changes in 0.2#
0.2.0#
Added ability to export
hiku.querynodes. Addedhiku.export.simpleexporter, which will export query into EDN data structureAdded debug mode for the
hiku.consoleapplication, showing Python tracebacks if debug mode is turned onImplemented
hiku.validate.query.QueryValidatorto validate query against graph definition before it’s executionImplemented
hiku.validate.graph.GraphValidatorto validate graph definitionAdded ability to define graph links with
hiku.types.Optionaltype:Link('link-to-foo', Optional[TypeRef['foo']], func, requires=None)
Added ability to query complex fields, which has a type of
Optional[Record[...]],Record[...]orSequence[Record[...]]as if they were linked edges:Edge('foo', [ Field('bar', Record[{'baz': Integer}], func), ])
Here
barfield should be queried as it was a link to the edge:[{:link-to-foo [{:bar [:baz]}]}]
Added ability to use scalar values in the expressions. Currently only integer numbers and strings are supported:
Expr('foo', foo_subgraph, func(S.this.foo, 'scalar'))
Implemented
hiku.expr.if_some()function in order to unpackhiku.types.Optionaltype in expressionsAdded ability to pass objects, required to execute query, using bound to the query context:
@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
hiku.sources.aiopgsource for using aiopg andhiku.executors.asyncio.AsyncIOExecutorto asynchronously load data from the PostgreSQL databaseAdded ability to define function arguments using types instead of queries:
@define(Record[{'foo': Integer}]) # instead of @define('[[:foo]]') def func(arg): return arg['foo'] + 1
Backward-incompatible changes#
Changed type of
hiku.graph.Field.optionsfromMapping[str, Option]toSequence[Option]Changed type of
hiku.graph.Link.optionsfromMapping[str, Option]toSequence[Option]Changed type of
hiku.graph.Edge.fieldsfromMapping[str, Union[Field, Link]]toSequence[Union[Field, Link]]Changed type of
hiku.query.Edge.fieldsfromMapping[str, Union[Field, Link]]toSequence[Union[Field, Link]]hiku.graph.Graphis not a subclass of thehiku.graph.Edgeanymore, all the root edges, fields and links should be defined in thehiku.graph.Rootedge. Nowhiku.graph.Graphcan contain only edgesAll
hiku.typesandhiku.typedef.typesare now subclasses oftype, instead of being instances oftypeRenamed
hiku.types.Typeintohiku.types.GenericMetaRenamed
hiku.types.BooleanTypeintohiku.types.BooleanRenamed
hiku.types.StringTypeintohiku.types.StringRenamed
hiku.types.IntegerTypeintohiku.types.IntegerRenamed
hiku.types.OptionTypeintohiku.types.OptionalRenamed
hiku.types.ListTypeintohiku.types.SequenceRenamed
hiku.types.DictTypeintohiku.types.MappingRenamed
hiku.types.RecordTypeintohiku.types.RecordRenamed
hiku.types.FunctionTypeintohiku.types.CallableRemoved
hiku.types.ContainerTypeRemoved
hiku.types.to_instance()Moved
hiku.typedef.types.TypeRefintohiku.types.TypeRefMoved
hiku.typedef.types.TypeRefMetaintohiku.types.TypeRefMetaReplaced required keyword arguments
to_listandedgein thehiku.graph.Linkclass by one second positional argument, which can have one of these values:TypeRef['foo']orOptional[TypeRef['foo']]instead ofedge='foo', to_list=FalseSequence[TypeRef['foo']]instead ofedge='foo', to_list=True
Before:
Link('foo', func, edge='bar', requires='id', to_list=True)
Now:
Link('foo', Sequence[TypeRef['bar']], func, requires='id')
Replaced required keyword arguments
to_listandedgein thehiku.sources.sqlalchemy.LinkQueryclass by one second positional argument, as inhiku.graph.LinkRenamed required keyword argument and corresponding instance attribute from
docintodescriptionin thehiku.graph.Field,hiku.graph.Link,hiku.graph.Edgeand in thehiku.sources.sqlalchemy.LinkclassesRenamed attribute of the
hiku.typedef.kinko.TypeDocfrom__type_doc__into__type_description__Moved constant
hiku.engine.Nothingto thehiku.graph.NothingRenamed attribute
hiku.result.Ref.storageintohiku.result.Ref.indexRenamed attribute
hiku.result.State.idxintohiku.result.State.indexhiku.sources.sqlalchemy.FieldsQueryandhiku.sources.sqlalchemy.LinkQuerynow require context keys instead of “connectable” objects (SQLAlchemy’s scoped session)Moved type
hiku.typedef.types.Unknownto thehiku.types.UnknownPositional
typeargument inhiku.graph.Fieldand inhiku.graph.Optionnow is required