ForeignKeyConstraint

pydantic model felis.datamodel.ForeignKeyConstraint

Table foreign key constraint model.

This constraint is used to define a foreign key relationship between two tables in the schema. There must be at least one column in the columns list, and at least one column in the referenced_columns list or a validation error will be raised.

Notes

These relationships will be reflected in the TAP_SCHEMA keys and key_columns data.

Parameters:

data (Any)

Fields:
Validators:
field columns: list[str] [Required]

The columns comprising the foreign key.

Constraints:
  • min_length = 1

Validated by:
field on_delete: Literal['CASCADE', 'SET NULL', 'SET DEFAULT', 'RESTRICT', 'NO ACTION'] | None = None

Action to take when the referenced row is deleted.

Validated by:
field on_update: Literal['CASCADE', 'SET NULL', 'SET DEFAULT', 'RESTRICT', 'NO ACTION'] | None = None

Action to take when the referenced row is updated.

Validated by:
field referenced_columns: list[str] [Required] (alias 'referencedColumns')

The columns referenced by the foreign key.

Constraints:
  • min_length = 1

Validated by:
field type: Literal['ForeignKey'] = 'ForeignKey' (alias '@type')

Type of the constraint.

Validated by:
validator check_column_lengths  »  all fields

Check that the columns and referenced_columns lists have the same length.

Returns:

The foreign key constraint being validated.

Return type:

ForeignKeyConstraint

Raises:

ValueError – Raised if the columns and referenced_columns lists do not have the same length.

serialize_type(value)

Ensure @type’ is included in serialized output.

Parameters:

value (str) – The value to serialize.

Returns:

The serialized value.

Return type:

str