diff --git a/core/dbt/artifacts/README.md b/core/dbt/artifacts/README.md index 5f6be858266..ffe112af558 100644 --- a/core/dbt/artifacts/README.md +++ b/core/dbt/artifacts/README.md @@ -35,9 +35,11 @@ All existing resources are defined under `dbt/artifacts/resources/v1`. Freely make incremental, non-breaking changes in-place to the latest major version of any artifact in mantle (via minor or patch bumps). The only changes that are fully forward and backward compatible are: 1. Adding a new field with a default 2. Deleting a field with a default - * This is compatible in terms of serialization and deserialization in mashumaro, but still may be surprising for consumers relying on the fields existence (e.g. `manifest["deleted_field]` will stop working unless the access was implemented safely ) + * This is compatible in terms of serialization and deserialization, but still may be lead to suprising behaviour: + * For artifact consumers relying on the fields existence (e.g. `manifest["deleted_field"]` will stop working unless the access was implemented safely) + * Old code (e.g. in dbt-core) that relies on the value of the deleted field may have surprising behaviour given only the default value will be set when instantiated from the new schema -These types of minor, non-reabking changes are tested by [tests/unit/artifacts/test_base_resource.py::TestMinorSchemaChange](https://github.com/dbt-labs/dbt-core/blob/main/tests/unit/artifacts/test_base_resource.py). +These types of minor, non-breaking changes are tested by [tests/unit/artifacts/test_base_resource.py::TestMinorSchemaChange](https://github.com/dbt-labs/dbt-core/blob/main/tests/unit/artifacts/test_base_resource.py). ### Breaking changes A breaking change is anything that: diff --git a/tests/unit/artifacts/test_base_resource.py b/tests/unit/artifacts/test_base_resource.py index 3799b24a434..9067bf7a205 100644 --- a/tests/unit/artifacts/test_base_resource.py +++ b/tests/unit/artifacts/test_base_resource.py @@ -7,7 +7,7 @@ @dataclass class BaseResourceWithDefaultField(BaseResource): - new_field_with_default: bool = True + field_with_default: bool = True class TestMinorSchemaChange: @@ -31,7 +31,7 @@ def base_resource_new_default_field(self): path="test_path", original_file_path="test_original_file_path", unique_id="test_unique_id", - new_field_with_default=False, + field_with_default=False, ) def test_serializing_new_default_field_is_backward_compatabile( @@ -46,7 +46,9 @@ def test_serializing_new_default_field_is_forward_compatible(self, base_resource def test_serializing_removed_default_field_is_backward_compatabile(self, base_resource): # old code (using old class with default field) can create an instance of itself given new data (class w/o default field) - BaseResourceWithDefaultField.from_dict(base_resource.to_dict()) + old_resource = BaseResourceWithDefaultField.from_dict(base_resource.to_dict()) + # set to the default value when not provided in data + assert old_resource.field_with_default is True def test_serializing_removed_default_field_is_forward_compatible( self, base_resource_new_default_field