diff --git a/src/bo4e_generator/custom_templates/BaseModel.jinja2 b/src/bo4e_generator/custom_templates/BaseModel.jinja2 index 589ba84..bf52df1 100644 --- a/src/bo4e_generator/custom_templates/BaseModel.jinja2 +++ b/src/bo4e_generator/custom_templates/BaseModel.jinja2 @@ -1,9 +1,9 @@ {%- if SQL and SQL['imports']%} {%- for class_name, module_path in SQL['imports'].items() %} {%- if module_path[:4] == 'enum'%} -from borm.models.{{ module_path }} import {{ class_name }} +from ibims.orm.models.{{ module_path }} import {{ class_name }} {%- elif module_path == 'Link'%} -from borm.models.many import {{ class_name }} +from ibims.orm.models.many import {{ class_name }} {%- else %} from {{ module_path }} import {{ class_name }} {%- endif %} @@ -13,7 +13,7 @@ from {{ module_path }} import {{ class_name }} from typing import TYPE_CHECKING if TYPE_CHECKING: {%- for class_name, module_path in SQL['relationimports'].items() %} - from borm.models.{{ module_path }} import {{ class_name }} + from ibims.orm.models.{{ module_path }} import {{ class_name }} {%- endfor -%} {%- endif %} {% for decorator in decorators -%} diff --git a/src/bo4e_generator/sqlparser.py b/src/bo4e_generator/sqlparser.py index 1575dc0..ba83410 100644 --- a/src/bo4e_generator/sqlparser.py +++ b/src/bo4e_generator/sqlparser.py @@ -42,14 +42,14 @@ def adapt_parse_for_sql( for schema_metadata in namespace.values(): if schema_metadata.module_path[0] != "enum": # list of fields which will be replaced by modified versions - del_fields = [] + del_fields = set() for field, val in schema_metadata.schema_parsed["properties"].items(): # type Any field if "type" not in str(val): add_relation, relation_imports = create_sql_any( field, schema_metadata.class_name, namespace, add_relation, relation_imports ) - del_fields.append(field) + del_fields.add(field) # modify decimal fields if "number" in str(val) and "string" in str(val): relation_imports[schema_metadata.class_name + "ADD"]["Decimal"] = "decimal" @@ -57,12 +57,12 @@ def adapt_parse_for_sql( add_relation, relation_imports = create_sql_list( field, schema_metadata.class_name, namespace, add_relation, relation_imports ) - del_fields.append(field) + del_fields.add(field) if "$ref" in str(val): # or "array" in str(val): add_relation, relation_imports = create_sql_field( field, schema_metadata.class_name, namespace, add_relation, relation_imports ) - del_fields.append(field) + del_fields.add(field) for field in del_fields: del schema_metadata.schema_parsed["properties"][field] # store the reduced version. The modified fields will be added in the BaseModel.jinja2 schema @@ -374,4 +374,4 @@ def format_code(code: str) -> str: perform isort and black on code """ code = black.format_str(code, mode=black.Mode()) - return isort.code(code, known_local_folder=["borm"]) + return isort.code(code, known_local_folder=["ibims"])