Skip to content

Commit 4ae0883

Browse files
authored
Forbid fields other than those defined by each model class (#752)
Also adjust models and query methods to account for the new strict fields: Ensure AssayTable.name is dropped on both sides of the conditional; don't return audit_log_id, similarly to most other table classes; remove author from SequencingGroupTable query fields as it is not present in SequencingGroupFilter; remove outdated links/_links field alias.
1 parent 091b26d commit 4ae0883

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

db/python/tables/assay.py

+1
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ async def get_assays_for_sequencing_group_ids(
549549
drow['external_ids'] = {drow.pop('name'): external_id}
550550
else:
551551
drow['external_ids'] = {}
552+
del drow['name']
552553

553554
sequencing_group_id = drow.pop('sequencing_group_id')
554555
projects.add(drow.pop('project'))

db/python/tables/sample.py

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class SampleTable(DbBase):
4949
'active',
5050
'type',
5151
'project',
52-
'audit_log_id',
5352
]
5453

5554
# region GETS

db/python/tables/sequencing_group.py

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class SequencingGroupTable(DbBase):
5959
'sg.technology',
6060
'sg.platform',
6161
'sg.meta',
62-
'sg.author',
6362
'sg.archived',
6463
]
6564
common_get_keys_str = ', '.join(common_get_keys)

models/base.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pydantic.main import BaseModel
1+
from pydantic.main import BaseModel, Extra
22

33
# annotate any external objects that must be instantiated with this
44
# type to force openapi generator to allow for Nones (it will actually allow Any)
@@ -8,6 +8,10 @@
88
class SMBase(BaseModel):
99
"""Base object for all models"""
1010

11+
class Config:
12+
"""Allow only the fields defined in each model class"""
13+
extra = Extra.forbid
14+
1115
@classmethod
1216
def from_dict(cls, d: dict):
1317
"""Create an object from a dictionary"""

models/models/web.py

-5
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,3 @@ class ProjectSummary(SMBase):
117117
seqr_sync_types: list[str]
118118

119119
links: PagingLinks | None
120-
121-
class Config:
122-
"""Config for ProjectSummaryResponse"""
123-
124-
fields = {'links': '_links'}

0 commit comments

Comments
 (0)