rewrite (data): Increase Column flexibility.

New Column field types.
Allow Column to be an attribute of a non-rowmodel.
Add `references` field to Column.
Add logging for registry attach.
Add support for alternative join types.
This commit is contained in:
2022-11-18 08:41:11 +02:00
parent e528e8d0b6
commit 56f66ec7d4
6 changed files with 50 additions and 12 deletions

View File

@@ -1,3 +1,4 @@
from typing import TypeVar
import logging
from collections import namedtuple
@@ -10,6 +11,8 @@ logger = logging.getLogger(__name__)
Version = namedtuple('Version', ('version', 'time', 'author'))
T = TypeVar('T', bound=Registry)
class Database(Connector):
# cursor_factory = AsyncLoggingCursor
@@ -19,9 +22,14 @@ class Database(Connector):
self.registries: dict[str, Registry] = {}
def load_registry(self, registry: Registry):
def load_registry(self, registry: T) -> T:
logger.debug(
f"Loading and binding registry '{registry.name}'.",
extra={'action': f"Reg {registry.name}"}
)
registry.bind(self)
self.registries[registry.name] = registry
return registry
async def version(self) -> Version:
"""