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
columnslist, and the reference target must be specified using eitherreferenced_columns(a list of global column IDs) orreference(the name of the referenced table and its columns). Exactly one of these must be provided or a validation error will be raised.Notes
These relationships will be reflected in the TAP_SCHEMA
keysandkey_columnsdata.- Parameters:
data (
Any)- Fields:
- Validators:
check_column_lengths»all fields
- 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 reference: ForeignKeyReference | None = None¶
The reference target given as a table name and column names.
This is the name-based style. Mutually exclusive with
referenced_columns.- Validated by:
- field referenced_columns: list[str] | None = None (alias 'referencedColumns')¶
The columns referenced by the foreign key, given as global column IDs.
This is the original, ID-based style. Mutually exclusive with
reference.- 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 foreign key specifies a reference target and that it references the same number of columns as it has source columns.
- Returns:
The foreign key constraint being validated.
- Return type:
- Raises:
ValueError – Raised if both reference styles are specified, if no reference target is specified, or if the number of source columns and referenced columns differ.