From f29f4d3e5ed043f56ff5388a9e15764f7f89bf0b Mon Sep 17 00:00:00 2001 From: Subhash Bhushan Date: Thu, 7 Oct 2021 10:05:39 -0700 Subject: [PATCH] Miscellaneous fixes --- CHANGELOG.rst | 14 +++++++++++--- src/protean/adapters/repository/elasticsearch.py | 1 - src/protean/cli.py | 2 +- src/protean/core/entity.py | 8 +++----- src/protean/domain/__init__.py | 2 +- .../postgresql/test_associations.py | 8 ++++---- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e4888923..7e974212 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,10 +1,18 @@ Release History =============== -Dev ---- +0.8.0 +----- -* Introduce state to Views to allow persistence +* Move `fields` module to be under main package +* Allow `List` fields to contain `Dict` objects +* Elasticsearch adapter bugfixes and model enhancements +* Make views stateful to allow persistence and retrieval +* Auto-generate Event's `message_id` +* Support pickling of Protean exceptions +* Bugfix - Fetch view objects instead of simply IDs in `cache.get_all()` +* Bugfix - Generate embedded ValueObject's data properly in `to_dict()` +* Bugfix - Derive SQLAlchemy field types correctly for embedded value object fields 0.7.0 ----- diff --git a/src/protean/adapters/repository/elasticsearch.py b/src/protean/adapters/repository/elasticsearch.py index 37d9d2be..fc923ed0 100644 --- a/src/protean/adapters/repository/elasticsearch.py +++ b/src/protean/adapters/repository/elasticsearch.py @@ -460,7 +460,6 @@ def _data_reset(self): ] == Database.ELASTICSEARCH.value and conn.indices.exists( model_cls._index._name ): - print(f"---> Deleting {model_cls}: {model_cls._index._name}") conn.delete_by_query( refresh=True, index=model_cls._index._name, diff --git a/src/protean/cli.py b/src/protean/cli.py index 84929436..476befe0 100644 --- a/src/protean/cli.py +++ b/src/protean/cli.py @@ -31,7 +31,7 @@ class NoDomainException(click.UsageError): @click.version_option() @click.pass_context def main(ctx): - """CLI utilities for the Protean""" + """CLI utilities for Protean""" if ctx.invoked_subcommand is None: click.echo(ctx.get_help()) diff --git a/src/protean/core/entity.py b/src/protean/core/entity.py index 25623ecd..c03e6e2a 100644 --- a/src/protean/core/entity.py +++ b/src/protean/core/entity.py @@ -252,11 +252,9 @@ def __init__(self, *template, **kwargs): # noqa: C901 # Load Identities id_field_obj = id_field(self) - if ( - not getattr(self, id_field_obj.field_name, None) - and type(id_field_obj) is Auto - ): - setattr(self, id_field_obj.field_name, generate_identity()) + if type(id_field_obj) is Auto: + if not getattr(self, id_field_obj.field_name, None): + setattr(self, id_field_obj.field_name, generate_identity()) loaded_fields.append(id_field_obj.field_name) # Load Associations diff --git a/src/protean/domain/__init__.py b/src/protean/domain/__init__.py index 8c386413..5b612c71 100644 --- a/src/protean/domain/__init__.py +++ b/src/protean/domain/__init__.py @@ -173,7 +173,7 @@ def __init__( self.register(Job) self.register(JobRepository) - def init(self): + def init(self): # noqa: C901 """ Parse the domain folder, and attach elements dynamically to the domain. Protean parses all files in the domain file's folder, as well as under it, diff --git a/tests/adapters/repository/sqlalchemy_repo/postgresql/test_associations.py b/tests/adapters/repository/sqlalchemy_repo/postgresql/test_associations.py index 8069119a..cc975397 100644 --- a/tests/adapters/repository/sqlalchemy_repo/postgresql/test_associations.py +++ b/tests/adapters/repository/sqlalchemy_repo/postgresql/test_associations.py @@ -16,15 +16,15 @@ class Meta: aggregate_cls = "Post" -class Permission(BaseValueObject): - dict_object = Dict() - - class Post(BaseAggregate): content = Text(required=True) comments = HasMany(Comment) +class Permission(BaseValueObject): + dict_object = Dict() + + class Audit(BaseAggregate): permission = ValueObject(Permission)