Skip to content

Commit

Permalink
minor fixes for ibims
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaDaniel committed Jul 30, 2024
1 parent f8ec004 commit a964774
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/bo4e_generator/custom_templates/BaseModel.jinja2
Original file line number Diff line number Diff line change
@@ -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 %}
Expand All @@ -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 -%}
Expand Down
10 changes: 5 additions & 5 deletions src/bo4e_generator/sqlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ 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"
if "array" in str(val) and "$ref" not in str(val):
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
Expand Down Expand Up @@ -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"])

0 comments on commit a964774

Please sign in to comment.