3
0
Fork 0

Compare commits

..

No commits in common. "34704acf24d1c3e1bed88897f14f29dd8883c7d4" and "481a6d95b0b5669f8dcc28757392ef806003063c" have entirely different histories.

3 changed files with 19 additions and 15 deletions

View file

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

View file

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

View file

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