schema: Continue

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-01-30 20:34:44 +01:00
commit c50c614f13
7 changed files with 223 additions and 52 deletions

View file

@ -1,19 +1,33 @@
# -*- coding: utf-8 -*-
from typing import Optional, List, Any
from typing import Optional, Any
from .Column import Column
from .ColumnSet import ColumnSet
class SingleForeignKey:
def __init__(self, child_col, parent_col):
def __init__(self, child_col: Column, parent_col: Column):
self.__child_col = child_col
self.__parent_col = parent_col
self.__iterable = (self.__child_col, self.__parent_col)
def __len__(self):
return 2
def __iter__(self):
yield from self.__iterable
def __repr__(self):
return f'{self.__child_col.table.name}.{self.__child_col.name} -> {self.__parent_col.table.name}.{self.__parent_col.name}'
def __getitem__(self, index):
return self.__iterable[index]
@property
def child_col(self):
def child_column(self):
return self.__child_col
@property
def parent_col(self):
def parent_column(self):
return self.__parent_col