Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

fix(mssql): prevent ambiguous error with aliases #241

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions odd_collector/adapters/mssql/adapter.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from collections import defaultdict
from typing import Dict, Generator, Set

from funcy import lpluck_attr
from odd_collector_sdk.domain.adapter import BaseAdapter
from odd_models.models import DataEntityList
from oddrn_generator import Generator, MssqlGenerator

from odd_collector.adapters.mssql.mappers.views import map_view
from odd_collector.domain.plugin import MSSQLPlugin

from .mappers.database import map_database
Expand Down Expand Up @@ -45,7 +43,7 @@ def get_data_entity_list(self) -> DataEntityList:

with self.repository as repository:
columns = repository.get_columns()
schemas: Dict[str, Set[str]] = defaultdict(set)
schemas: dict[str, set[str]] = defaultdict(set)

tables_data_entities = []
for table in repository.get_tables():
Expand Down
2 changes: 2 additions & 0 deletions odd_collector/adapters/mssql/logger.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from odd_collector_sdk.logger import logger

logger = logger
35 changes: 20 additions & 15 deletions odd_collector/adapters/mssql/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,29 @@ def get_columns_for(self, database: str, schema: str, name: str) -> list[Column]
AND C.table_schema = PK.table_schema
AND C.table_name = PK.table_name
AND C.column_name = PK.column_name
ORDER BY table_catalog, table_schema, table_name, ordinal_position
ORDER BY C.table_catalog, C.table_schema, C.table_name, C.ordinal_position
"""

VIEWS_QUERY: str = """
select
tvu.view_catalog as view_catalog,
tvu.view_schema as view_schema,
tvu.view_name as view_name,
tvu.table_catalog as table_catalog,
tvu.table_schema as table_schema,
tvu.table_name as table_name,
tb.table_type as table_type
from information_schema.view_table_usage tvu
inner join information_schema.tables tb
on tvu.table_catalog = tb.table_catalog
and tvu.table_schema = tb.table_schema
and tvu.table_name = tb.table_name
order by view_catalog, view_schema, view_name, table_catalog, table_schema, table_name
select
tvu.view_catalog as view_catalog,
tvu.view_schema as view_schema,
tvu.view_name as view_name,
tvu.table_catalog as table_catalog,
tvu.table_schema as table_schema,
tvu.table_name as table_name,
tb.table_type as table_type
from information_schema.view_table_usage tvu
inner join information_schema.tables tb
on tvu.table_catalog = tb.table_catalog
and tvu.table_schema = tb.table_schema
and tvu.table_name = tb.table_name
order by tvu.view_catalog,
tvu.view_schema,
tvu.view_name,
tvu.table_catalog,
tvu.table_schema,
tvu.table_name
"""


Expand Down
Loading