From dcb707e41d7c8b5c20c76d30cd11d0865dc71000 Mon Sep 17 00:00:00 2001 From: Levente Hunyadi Date: Wed, 31 Jan 2024 20:50:00 +0100 Subject: [PATCH] Ensure discoverability of orphaned enumeration objects --- pysqlsync/dialect/oracle/discovery.py | 4 +--- pysqlsync/dialect/postgresql/discovery.py | 2 +- pysqlsync/formation/object_types.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pysqlsync/dialect/oracle/discovery.py b/pysqlsync/dialect/oracle/discovery.py index 40d9972..3a7b8a4 100644 --- a/pysqlsync/dialect/oracle/discovery.py +++ b/pysqlsync/dialect/oracle/discovery.py @@ -232,8 +232,6 @@ async def _get_namespace(self, namespace_id: Optional[LocalId] = None) -> Namesp tables.append(table) if tables: - return self.factory.namespace_class( - LocalId(""), enums=[], structs=[], tables=tables - ) + return self.factory.namespace_class(enums=[], structs=[], tables=tables) else: return self.factory.namespace_class() diff --git a/pysqlsync/dialect/postgresql/discovery.py b/pysqlsync/dialect/postgresql/discovery.py index 0012dbf..912fc63 100644 --- a/pysqlsync/dialect/postgresql/discovery.py +++ b/pysqlsync/dialect/postgresql/discovery.py @@ -392,7 +392,7 @@ async def get_namespace(self, namespace_id: LocalId) -> Namespace: table = await self.get_table(QualifiedId(namespace_id.id, table_name)) tables.append(table) - if tables: + if enums or structs or tables: return self.factory.namespace_class( namespace_id, enums=enums, structs=structs, tables=tables ) diff --git a/pysqlsync/formation/object_types.py b/pysqlsync/formation/object_types.py index 3469596..3753161 100644 --- a/pysqlsync/formation/object_types.py +++ b/pysqlsync/formation/object_types.py @@ -534,6 +534,16 @@ def __init__(self) -> None: def __init__(self, name: LocalId) -> None: ... + @overload + def __init__( + self, + *, + enums: list[EnumType], + structs: list[StructType], + tables: list[Table], + ) -> None: + ... + @overload def __init__( self,