Skip to content

Commit

Permalink
Add utype as field on BaseObject
Browse files Browse the repository at this point in the history
Since utype can be assigned to schemas, tables, columns, and foreign
keys in TAP_SCHEMA, it makes sense to have utype as a field on the
base Pydantic object rather than just on column.
  • Loading branch information
JeremyMcCormick committed Apr 3, 2024
1 parent d8d37f7 commit 37b235e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions python/felis/datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class BaseObject(BaseModel):
`BaseObject.Config.require_description` is set to `True` by the user.
"""

votable_utype: str | None = Field(None, alias="votable:utype")
"""The VOTable utype (usage-specific or unique type) of the object."""

@model_validator(mode="before")
@classmethod
def check_description(cls, values: dict[str, Any]) -> dict[str, Any]:
Expand Down Expand Up @@ -171,9 +174,6 @@ class Column(BaseObject):
"""TAP_SCHEMA indication that this column is defined by an IVOA standard.
"""

votable_utype: str | None = Field(None, alias="votable:utype")
"""The VOTable utype (usage-specific or unique type) of the column."""

votable_xtype: str | None = Field(None, alias="votable:xtype")
"""The VOTable xtype (extended type) of the column."""

Expand Down
6 changes: 3 additions & 3 deletions python/felis/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def visit_schema(self, schema_obj: Schema) -> None:

schema.schema_name = self._schema_name()
schema.description = schema_obj.description
schema.utype = None # FIXME: Hard-coded to None
schema.utype = schema_obj.votable_utype
schema.schema_index = schema_obj.tap_schema_index

if self.engine is not None:
Expand Down Expand Up @@ -238,7 +238,7 @@ def visit_table(self, table_obj: Table, schema_obj: Schema) -> tuple:
table.schema_name = self._schema_name()
table.table_name = self._table_name(table_obj.name)
table.table_type = "table"
table.utype = None # FIXME: Hard-coded table utype to None
table.utype = table_obj.votable_utype
table.description = table_obj.description
table.table_index = table_obj.tap_table_index

Expand Down Expand Up @@ -332,7 +332,7 @@ def visit_constraint(self, constraint_obj: Constraint) -> tuple:
if constraint_type == "ForeignKey":
constraint_name = constraint_obj.name
description = constraint_obj.description
utype = None # FIXME: Hard-coded constraint utype to None
utype = constraint_obj.votable_utype

columns = [self.graph_index[col_id] for col_id in getattr(constraint_obj, "columns", [])]
refcolumns = [
Expand Down

0 comments on commit 37b235e

Please sign in to comment.