3
0
Fork 0

Compare commits

...

3 commits

3 changed files with 15 additions and 19 deletions

View file

@ -15,16 +15,6 @@ class ${model_name}(model.Base):
${description}
"""
__tablename__ = "${table_name}"
% if any([c["data_type"]["type"] == "_fk_uuid_" for c in columns]):
__table_args__ = (
% for column in columns:
% if column["data_type"]["type"] == "_fk_uuid_":
sa.ForeignKeyConstraint(["${column['name']}"], ["${column['data_type']['reference']}.uuid"],
name="${table_name}_fk_${column['data_type']['reference']}"),
% endif
% endfor
)
% endif
% if versioned:
% if all([c["versioned"] for c in columns]):
__versioned__ = {}
@ -48,17 +38,23 @@ class ${model_name}(model.Base):
% if column["name"] == "uuid":
uuid = model.uuid_column()
% else:
${column["name"]} = sa.Column(${column["formatted_data_type"]}, nullable=${column["nullable"]}, doc="""
${column["description"] or ""}
""")
% if column["data_type"]["type"] == "_fk_uuid_" and column["relationship"]:
% elif column["data_type"]["type"] == "_fk_uuid_":
${column["name"]} = model.uuid_fk_column("${column['data_type']['reference']}.uuid",
nullable=${column["nullable"]})
% if column["relationship"]:
${column["relationship"]["name"]} = orm.relationship(
"${column['relationship']['reference_model']}",
doc="""
${column["description"] or ""}
""")
% endif
% else:
${column["name"]} = sa.Column(
${column["formatted_data_type"]},
nullable=${column["nullable"]},
doc="""
${column["description"] or ""}
""")
% endif
% endfor

View file

@ -21,7 +21,8 @@
% if master.has_rows:
<div style="display: flex; flex-direction: column;">
<div style="display: flex; justify-content: space-between;">
<div class="block"
style="display: flex; justify-content: space-between;">
## main form
<div style="flex-grow: 1;">
@ -34,7 +35,6 @@
</div>
## rows grid
<br />
<h4 class="block is-size-4">${master.get_rows_title() or ''}</h4>
${rows_grid.render_vue_tag()}
</div>

View file

@ -818,7 +818,7 @@
} else if (dataType.type == 'UUID') {
return `UUID()`
} else if (dataType.type == '_fk_uuid_') {
return 'sa.String(length=32)'
return `UUID()`
} else if (dataType.type == '_other_') {
return dataType.literal
} else {
@ -947,7 +947,7 @@
} else {
this.modelImportProblem = false
this.modelImported = this.modelImportName
this.revisionMessage = `add table for ${"$"}{this.tableModelTitlePlural}`
this.revisionMessage = `add ${"$"}{this.tableModelTitlePlural}`
}
}, 200)
})