Skip to content

Commit

Permalink
Put back fk_target_field_id for model export (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
gouline authored Jan 25, 2024
1 parent f5124dd commit 5e62ca4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dbtmetabase/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def __export_column(

table_key = f"{schema_name}.{model_name}"
column_name = column.name.upper()
column_label = f"{schema_name}.{model_name}.{column_name}"

api_field = ctx.tables.get(table_key, {}).get("fields", {}).get(column_name)
if not api_field:
Expand All @@ -231,7 +232,6 @@ def __export_column(
column.fk_target_field.upper() if column.fk_target_field else None
)
fk_target_field_label = f"{fk_target_table_name}.{fk_target_field_name}"
column_label = f"{table_key}.{column_name}"

if fk_target_table_name and fk_target_field_name:
fk_target_field = (
Expand All @@ -240,6 +240,7 @@ def __export_column(
.get(fk_target_field_name)
)
if fk_target_field:
fk_target_field_id = fk_target_field.get("id")
if fk_target_field.get(semantic_type_key) != "type/PK":
_logger.info(
"Field '%s' will be updated as primary key for foreign key '%s'",
Expand Down Expand Up @@ -315,7 +316,6 @@ def __export_column(
):
body_field[semantic_type_key] = column.semantic_type or None

column_label = f"{schema_name}.{model_name}.{column_name}"
if body_field:
ctx.update(entity=api_field, change=body_field, label=column_label)
_logger.info(
Expand Down
1 change: 1 addition & 0 deletions tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_filter(self):
def test_null_value(self):
self.assertIsNotNone(NullValue)
self.assertFalse(NullValue)
self.assertIs(NullValue, NullValue)

def test_safe_name(self):
self.assertEqual(
Expand Down

0 comments on commit 5e62ca4

Please sign in to comment.