fix: handle None in catalog contstructor (#18)
This commit is contained in:
parent
507b75a968
commit
80babe642f
2 changed files with 14 additions and 5 deletions
|
|
@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Fixes a crash caused by ODBC drivers that return non-standard data from a call to `cursor.tables()` ([tconbeer/harlequin#780](https://github.com/tconbeer/harlequin/issues/780) - thank you [@khalid-talakshi](https://github.com/khalid-talakshi)!).
|
||||||
|
|
||||||
## [0.3.0] - 2025-02-25
|
## [0.3.0] - 2025-02-25
|
||||||
|
|
||||||
- The Data Catalog now displays all databases on the connected server, not just the currently-connected database ([tconbeer/harlequin#415](https://github.com/tconbeer/harlequin/discussions/415)).
|
- The Data Catalog now displays all databases on the connected server, not just the currently-connected database ([tconbeer/harlequin#415](https://github.com/tconbeer/harlequin/discussions/415)).
|
||||||
|
|
|
||||||
|
|
@ -148,12 +148,19 @@ class HarlequinOdbcConnection(HarlequinConnection):
|
||||||
cur = self.aux_conn.cursor()
|
cur = self.aux_conn.cursor()
|
||||||
catalog: dict[str, dict[str, list[tuple[str, str]]]] = {}
|
catalog: dict[str, dict[str, list[tuple[str, str]]]] = {}
|
||||||
for db_name, schema_name, rel_name, rel_type, *_ in cur.tables(catalog="%"):
|
for db_name, schema_name, rel_name, rel_type, *_ in cur.tables(catalog="%"):
|
||||||
|
if db_name is None:
|
||||||
|
continue
|
||||||
if db_name not in catalog:
|
if db_name not in catalog:
|
||||||
catalog[db_name] = {schema_name: [(rel_name, rel_type)]}
|
catalog[db_name] = dict()
|
||||||
elif schema_name not in catalog[db_name]:
|
|
||||||
catalog[db_name][schema_name] = [(rel_name, rel_type)]
|
if schema_name is None:
|
||||||
else:
|
continue
|
||||||
catalog[db_name][schema_name].append((rel_name, rel_type))
|
if schema_name not in catalog[db_name]:
|
||||||
|
catalog[db_name][schema_name] = list()
|
||||||
|
|
||||||
|
if rel_name is not None:
|
||||||
|
catalog[db_name][schema_name].append((rel_name, rel_type or ""))
|
||||||
|
|
||||||
return catalog
|
return catalog
|
||||||
|
|
||||||
def _list_columns_in_relation(
|
def _list_columns_in_relation(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue