Skip to content

Generate SQL Models#19

Merged
DeltaDaniel merged 68 commits intomainfrom
DDB/create_SQLModels
Mar 4, 2024
Merged

Generate SQL Models#19
DeltaDaniel merged 68 commits intomainfrom
DDB/create_SQLModels

Conversation

@DeltaDaniel
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Collaborator

@lord-haffi lord-haffi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, hatte das vor ein paar Tage reviewed, war aber alles noch auf Pending - vergessen auf den grünen Button zu klicken 🙄
Versuch gerne mal den Decimal-Regex wegzulassen. Eigentlich sollte der Bug gefixt sein. Ansonsten passt das so für mich, gebe dir schonmal nen Approve 👍

Comment thread src/bo4e_generator/sqlparser.py Outdated
Comment on lines +32 to +36
def make_decimal(field: str) -> str:
"""
turns Union type float or str into Decimal type
"""
return re.sub(r"float \| str", "Decimal", field)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mittlerweile überflüssig. Der Bug ist behoben, der Typ wird nun nicht mehr in float | str übersetzt, sondern direkt in Decimal.

Comment thread src/bo4e_generator/sqlparser.py Outdated
Comment on lines +68 to +70
# add_relation, relation_imports = create_sql_field(
# field, schema_metadata.class_name, namespace, add_relation, relation_imports
# )
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kann das weg🔥?

Comment on lines +55 to +66
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)
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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generell wäre es natürlich schöner, expliziter ranzugehen, als in der String-Übersetzung zu suchen. Im BO4E-Schema-Tool hab ich z.B. Schemas hinterlegt, um diese JSON-Schemas in eine Python-Objekt-Struktur zu überführen. Die kann man dann besser und sicherer analysieren.
Passt jetzt so für mich, nur fürs nächste Mal als Tipp ;)

Comment thread src/bo4e_generator/sqlparser.py Outdated
Comment thread src/bo4e_generator/sqlparser.py Outdated
Comment thread src/bo4e_generator/sqlparser.py Outdated
Comment thread src/bo4e_generator/sqlparser.py Outdated
DeltaDaniel and others added 10 commits February 20, 2024 10:36
Co-authored-by: Leon Haffmans <49658102+lord-haffi@users.noreply.github.com>
Co-authored-by: Leon Haffmans <49658102+lord-haffi@users.noreply.github.com>
Co-authored-by: Leon Haffmans <49658102+lord-haffi@users.noreply.github.com>
Co-authored-by: Leon Haffmans <49658102+lord-haffi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants