From 87d7295334297f45b8400a9084f8031a2de12bea Mon Sep 17 00:00:00 2001 From: Leah Tacke genannt Unterberg <leah.tgu@pads.rwth-aachen.de> Date: Thu, 8 May 2025 13:05:55 +0200 Subject: [PATCH] maybe fixed another syntax error --- .../representation/sql_representation.py | 16 ++++++++-------- mitm_tooling/transformation/sql/into_mappings.py | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mitm_tooling/representation/sql_representation.py b/mitm_tooling/representation/sql_representation.py index d9a1656..dbfbb62 100644 --- a/mitm_tooling/representation/sql_representation.py +++ b/mitm_tooling/representation/sql_representation.py @@ -74,12 +74,12 @@ def mk_link_table_name(mitm: MITM, concept: ConceptName, type_name: RelationName return mk_type_table_name(mitm, concept, type_name) + '_' + fk_name.lower() -def has_type_tables(mitm: MITM, concept: ConceptName) -> bool: - return get_mitm_def(mitm).get_properties(concept).permit_attributes +def has_type_tables(mitm_def: MITMDefinition, concept: ConceptName) -> bool: + return mitm_def.get_properties(concept).permit_attributes -def has_natural_pk(mitm: MITM, concept: ConceptName) -> bool: - return len(get_mitm_def(mitm).get_identity(concept)) > 0 +def has_natural_pk(mitm_def: MITMDefinition, concept: ConceptName) -> bool: + return len(mitm_def.get_identity(concept)) > 0 def pick_table_pk(mitm: MITM, concept: ConceptName, created_columns: ColumnsDict) -> ColumnsDict | None: @@ -87,7 +87,7 @@ def pick_table_pk(mitm: MITM, concept: ConceptName, created_columns: ColumnsDict concept_properties, concept_relations = mitm_def.get(concept) prepended_cols = None - if not has_natural_pk(mitm, concept): + if not has_natural_pk(mitm_def, concept): prepended_cols = lambda: [_within_concept_id_col(mitm, concept)] names, mapped_names = map_col_groups(mitm_def, concept, { 'kind': lambda: 'kind', @@ -193,7 +193,7 @@ def _gen_denormalized_views(mitm: MITM, concept_tables: ConceptTablesDict, type_ for concept in mitm_def.get_leafs(main_concept): view_name = mk_concept_table_name(mitm, concept) + '_denormalized_view' q = None - if has_type_tables(mitm, concept): + if has_type_tables(mitm_def, concept): selections = [] for leaf_concept in mitm_def.get_leafs(concept): @@ -288,7 +288,7 @@ def mk_sql_rep_schema(header: Header, _gen_foreign_key_constraints,) if not skip_fk_constraints else base_schema_item_generators for he in header.header_entries: he_concept = he.concept - if has_type_tables(header.mitm, he_concept): + if has_type_tables(mitm_def, he_concept): concept_properties, concept_relations = mitm_def.get(he_concept) table_name = mk_type_table_name(header.mitm, he_concept, he.type_name) @@ -364,7 +364,7 @@ def _insert_type_df(conn: sa.Connection, type_df = type_df.assign(**{concept_id_col_name: artificial_ids}) conn.execute(t_concept.insert(), _df_to_table_records(type_df, t_concept)) inserted_rows = no_instances - if has_type_tables(mitm, concept): + if has_type_tables(mitm_def, concept): # generated_ids = conn.execute(sa.select(t_concept.columns[concept_id_col_name])).scalars() t_type = sql_rep_schema.type_tables[concept][type_name] conn.execute(t_type.insert(), _df_to_table_records(type_df, t_type)) diff --git a/mitm_tooling/transformation/sql/into_mappings.py b/mitm_tooling/transformation/sql/into_mappings.py index 98f5a0c..8e7e2f0 100644 --- a/mitm_tooling/transformation/sql/into_mappings.py +++ b/mitm_tooling/transformation/sql/into_mappings.py @@ -1,7 +1,6 @@ from mitm_tooling.extraction.sql.data_models import SourceDBType from mitm_tooling.extraction.sql.mapping import ConceptMapping, ForeignRelation from mitm_tooling.representation import Header, SQLRepresentationSchema -from mitm_tooling.representation.sql_representation import has_type_tables def sql_rep_into_mappings(header: Header, sql_rep_schema: SQLRepresentationSchema) -> list[ConceptMapping]: -- GitLab