Skip to content

Commit 1380088

Browse files
Lingling PengLingling Peng
authored andcommitted
fix select column dataclass and one test
1 parent dfd4460 commit 1380088

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎synapseclient/models/mixins/table_components.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,6 @@ def construct_rownames(query_result_bundle, offset=0):
410410
rows = rowset.rows
411411
headers = rowset.headers
412412

413-
if not rows or not headers:
414-
raise ValueError("The provided rowset is missing 'rows' or 'headers' data.")
415-
416413
offset += len(rows)
417414
series = collections.OrderedDict()
418415

‎synapseclient/models/table_components.py‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,10 @@ class SelectColumn:
648648
This result is modeled from: <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/table/SelectColumn.html>
649649
"""
650650

651-
name: str
651+
name: Optional[str] = None
652652
"""The required display name of the column"""
653653

654-
column_type: ColumnType
654+
column_type: Optional[ColumnType] = None
655655
"""The column type determines the type of data that can be stored in a column.
656656
Switching between types (using a transaction with TableUpdateTransactionRequest
657657
in the "changes" list) is generally allowed except for switching to "_LIST"
@@ -664,9 +664,16 @@ class SelectColumn:
664664
@classmethod
665665
def fill_from_dict(cls, data: Dict[str, Any]) -> "SelectColumn":
666666
"""Create a SelectColumn from a dictionary response."""
667+
column_type = None
668+
column_type_value = data.get("columnType")
669+
if column_type_value:
670+
try:
671+
column_type = ColumnType(column_type_value)
672+
except ValueError:
673+
column_type = None
667674
return cls(
668-
name=data.get("name", ""),
669-
column_type=ColumnType(data.get("columnType", None)),
675+
name=data.get("name"),
676+
column_type=column_type,
670677
id=data.get("id"),
671678
)
672679

0 commit comments

Comments
 (0)