mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
schema.Table: Add property add_row_location_rule and friends
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
9b1650b58f
commit
5ca775eb82
1 changed files with 17 additions and 0 deletions
|
|
@ -38,6 +38,7 @@ class Table(abc.ABC): # export
|
||||||
self.__base_location_rule: Optional[Iterable[str]] = None
|
self.__base_location_rule: Optional[Iterable[str]] = None
|
||||||
self.__location_rule: Optional[Iterable[str]] = None
|
self.__location_rule: Optional[Iterable[str]] = None
|
||||||
self.__row_location_rule: Optional[Iterable[str]] = None
|
self.__row_location_rule: Optional[Iterable[str]] = None
|
||||||
|
self.__add_row_location_rule: Optional[Iterable[str]] = None
|
||||||
self.__foreign_keys_to_parent_table: Optional[OrderedDict[str, Any]] = None
|
self.__foreign_keys_to_parent_table: Optional[OrderedDict[str, Any]] = None
|
||||||
self.__relationships: Optional[list[tuple[str, Self]]] = None
|
self.__relationships: Optional[list[tuple[str, Self]]] = None
|
||||||
self.__model_class: Optional[Any] = None
|
self.__model_class: Optional[Any] = None
|
||||||
|
|
@ -168,6 +169,9 @@ class Table(abc.ABC): # export
|
||||||
ret += f'/<{col}>'
|
ret += f'/<{col}>'
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def _add_row_location_rule(self) -> Optional[str]:
|
||||||
|
return self._location_rule() + '/new'
|
||||||
|
|
||||||
# -- To be used
|
# -- To be used
|
||||||
|
|
||||||
def column_default(self, name) -> Any:
|
def column_default(self, name) -> Any:
|
||||||
|
|
@ -251,6 +255,19 @@ class Table(abc.ABC): # export
|
||||||
ret = re.sub(f'<{col}>', quote_plus(quote_plus(str(kwargs[col]))), ret)
|
ret = re.sub(f'<{col}>', quote_plus(quote_plus(str(kwargs[col]))), ret)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@property
|
||||||
|
def add_row_location_rule(self):
|
||||||
|
if self.__add_row_location_rule is None:
|
||||||
|
self.__add_row_location_rule = self._add_row_location_rule()
|
||||||
|
return self.__add_row_location_rule
|
||||||
|
|
||||||
|
def add_row_location(self, *args, **kwargs) -> Optional[str]:
|
||||||
|
ret = self.add_row_location_rule
|
||||||
|
for col in self.primary_keys:
|
||||||
|
if col in kwargs: # FIXME: Poor man's row location assembly
|
||||||
|
ret = re.sub(f'<{col}>', quote_plus(quote_plus(str(kwargs[col]))), ret)
|
||||||
|
return ret
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def primary_keys(self) -> Iterable[str]:
|
def primary_keys(self) -> Iterable[str]:
|
||||||
if self.__primary_keys is None:
|
if self.__primary_keys is None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue