Skip to content

Commit

Permalink
Handle unknown enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
shri committed Sep 4, 2024
1 parent 570f584 commit eb82c37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/db/models/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def process_result_value(self, value, dialect):
"""Convert JSON format to Python object when reading from the database."""
if value and isinstance(value, dict):
obj = Funding.from_dict(value)
obj.round_name = FundingRound(obj.round_name) if obj.round_name else FundingRound.SERIES_UNKNOWN
try:
obj.round_name = FundingRound(obj.round_name)
except ValueError:
obj.round_name = FundingRound.SERIES_UNKNOWN
return obj
return None

Expand Down
1 change: 1 addition & 0 deletions src/app/lib/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class FundingRound(enum.Enum):
SERIES_E = "Series E"
SERIES_UNKNOWN = "Series Unknown"
PRIVATE_EQUITY = "Private Equity"
EQUITY_CROWDFUNDING = "Equity Crowdfunding"
PUBLIC = "Public"


Expand Down

0 comments on commit eb82c37

Please sign in to comment.