Skip to content

Commit 04a3b3c

Browse files
authored
More fixes for native types (#287)
1 parent e8d3fdc commit 04a3b3c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/dl_core/dl_core/db/native_type_schema.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,18 @@ class Meta:
4949
# We need this because older dataset versions have `conn_type` attributes in native type objects,
5050
# but this attribute is no longer present in current code.
5151
# To avoid this conflict we need to ignore extra attributes.
52-
# TODO: Eventually dfatasets should be migrated so that this can be removed
52+
# TODO: Eventually datasets should be migrated so that this can be removed
5353
unknown = EXCLUDE
5454

5555
TARGET_CLS: ClassVar[Type[_TARGET_TV]] # type: ignore # 2024-01-24 # TODO: ClassVar cannot contain type variables [misc]
5656

5757
@post_load(pass_many=False)
5858
def to_object(self, data: dict, **_): # type: ignore # TODO: fix
59+
if "conn_type" in data:
60+
# TODO: Remove once all datasets have been migrated
61+
data = data.copy()
62+
data.pop("conn_type")
63+
5964
return self.TARGET_CLS(**data) # type: ignore # TODO: fix
6065

6166

@@ -105,6 +110,10 @@ class ClickHouseDateTime64WithTZNativeTypeSchema(ClickHouseDateTime64NativeTypeS
105110
class OneOfNativeTypeSchemaBase(OneOfSchema):
106111
"""(OneOf (Native Type) Storage Schema)"""
107112

113+
class Meta:
114+
# Same as above in `NativeTypeSchemaBase`, to ignore `conn_type`
115+
unknown = EXCLUDE
116+
108117
type_field = "native_type_class_name"
109118
type_schemas = {
110119
schema.TARGET_CLS.native_type_class_name: schema

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Any
44

55
from marshmallow import (
6+
EXCLUDE,
67
Schema,
78
fields,
89
post_load,
@@ -16,11 +17,16 @@
1617
class NativeTypeSchema(Schema):
1718
"""(currently used for uploads / ProviderConnection)"""
1819

20+
class Meta:
21+
# Same as in `NativeTypeSchemaBase`, to ignore `conn_type`
22+
unknown = EXCLUDE
23+
1924
name = fields.String()
2025

2126
@post_load(pass_many=False)
2227
def to_object(self, data: dict[str, Any], **kwargs: Any) -> Any:
2328
if "conn_type" in data:
29+
# TODO: Remove once all datasets have been migrated
2430
data = data.copy()
2531
data.pop("conn_type")
2632
return GenericNativeType(**data)

0 commit comments

Comments
 (0)