Skip to content

Commit

Permalink
Implement Shahim's suggestion to write a "NULL" for empty enums.
Browse files Browse the repository at this point in the history
See #85.
  • Loading branch information
gaurav committed Oct 5, 2021
1 parent 47cde88 commit 7ae64a3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion vendor/sheet2linkml/sheet2linkml/source/gsheetmodel/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,22 @@ def as_linkml(self, root_uri) -> EnumDefinition:
self.mappings.set_mappings_on_element(enum)

# Now generate LinkML for all of the values.
enum.permissible_values = {
pv_values = {
str(enum_value.name): enum_value.as_linkml(root_uri)
for enum_value in self.values
}

# If we have no permissible values, then define a single PV named "null"
# (see https://github.com/cancerDHC/ccdhmodel/issues/85 for details)
if len(pv_values) == 0:
pv_values = {
'NULL': PermissibleValue(
text='NULL'
)
}

enum.permissible_values = pv_values

return enum


Expand Down

0 comments on commit 7ae64a3

Please sign in to comment.