mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
33 lines
830 B
Python
33 lines
830 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Optional, Any
|
|
|
|
from .Column import Column
|
|
from .ColumnSet import ColumnSet
|
|
|
|
class SingleForeignKey:
|
|
|
|
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_column(self):
|
|
return self.__child_col
|
|
|
|
@property
|
|
def parent_column(self):
|
|
return self.__parent_col
|