Skip to content

Commit cfb30cd

Browse files
authored
Compatibility fix after removal of conn_types from native types (#283)
1 parent 3c3a055 commit cfb30cd

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/dl_core/dl_core/db/native_type_schema.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
)
1818

1919
from marshmallow import (
20+
EXCLUDE,
2021
Schema,
2122
fields,
2223
post_load,
@@ -43,6 +44,14 @@
4344
class NativeTypeSchemaBase(Schema, Generic[_TARGET_TV]):
4445
"""(Shared ((Native Type) Storage Schema)), common base class for NT schemas."""
4546

47+
class Meta:
48+
# This crutch allows the schema to ignore unknown attributes.
49+
# We need this because older dataset versions have `conn_type` attributes in native type objects,
50+
# but this attribute is no longer present in current code.
51+
# To avoid this conflict we need to ignore extra attributes.
52+
# TODO: Eventually dfatasets should be migrated so that this can be removed
53+
unknown = EXCLUDE
54+
4655
TARGET_CLS: ClassVar[Type[_TARGET_TV]] # type: ignore # 2024-01-24 # TODO: ClassVar cannot contain type variables [misc]
4756

4857
@post_load(pass_many=False)

lib/dl_core/dl_core/us_manager/storage_schemas/base_types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class NativeTypeSchema(Schema):
2020

2121
@post_load(pass_many=False)
2222
def to_object(self, data: dict[str, Any], **kwargs: Any) -> Any:
23+
if "conn_type" in data:
24+
data = data.copy()
25+
data.pop("conn_type")
2326
return GenericNativeType(**data)
2427

2528

0 commit comments

Comments
 (0)