Enterprise Architect 12的数据库模型Bug(一)
首先,笔者目前刚刚切换用到EA版本12.0.1210。之前用的v9.1版本,这里我不得不吐槽EA12的Bug
这个Bug是关于数据库模型generate DLL的问题
它导出的SQL脚本有以下问题。
1、SET FOREIGN_KEY_CHECKS=0 和SET FOREIGN_KEY_CHECKS=1末尾忘了分号
2、对于表的属性在设计的时候是Tag枚举,但是在DLL模板里始终无法找到CHARSET和COLLATE属性;原以为可以tableProperty能找到,发现他只有内置的ENGINE引擎属性;
3、最蛋疼的是对0和空字符''不能智能补充DEFAULT修饰符;(导致SQL执行失败的元凶)
好吧,我既然把我发现的问题阐述了,那么我就用比较笨的办法来解决上面3个问题。
操作步骤如下
1、打开菜单栏PACKAGE->Database Enginneering->Edit DLL Templates
2、下拉选择语种MySQL,并选中脚本列表里的"DLL script File",点右侧代码面板内,按Ctrl+F搜索“SET FOREIGN_KEY_CHECKS=”,有2处地方;分别加入分号;
3、找DLL Create Table脚本,完整修改如下
%if ddlOptionGenerateTable != "T"%
%endTemplate%
%PI="\\n"%
$SnapShotName = %DDLName("EA", "TABLE", "INCLUDE_OWNER")%
%EXECUTE_CURRENT($SnapShotName, "Create Table", 590)%
CREATE TABLE %DDLName("EA", "TABLE", "INCLUDE_OWNER", "INCLUDE_SURROUND")%
$tableContent = %list="DDLColumnDefinition" @separator="\\n" @indent="\\t"%
$tableContent += "\\n"
$tableContent += %list="DDLTableConstraint" @separator="\\n" @indent="\\t" constraintProperty:"TYPE" == "PK"%
%if ddlOptionGenerateSeparateConstraint != "T"%
$tableContent += %list="DDLTableConstraint" @separator="\\n" @indent="\\t" constraintProperty:"TYPE" != "PK" and constraintProperty:"TYPE" != "FK" and constraintProperty:"TYPE" != "trigger"%
$tableContent += "\\n"
$tableContent += %list="DDLTableConstraint" @separator="\\n" @indent="\\t" constraintProperty:"TYPE" == "FK"%
$tableContent += "\\n"
%endIf%
$tableContent = %REMOVE_LAST_SEPARATOR($tableContent, ",")%
$tableContent = %TRIM($tableContent, "\\n")%
(
$tableContent
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
%PI("I", "")%
%if tableProperty:"Engine" != ""%
ENGINE=%tableProperty:"Engine"%
%endIf%
$tableComment = %DDLTableLevelComment%
%if $tableComment != ""%
$tableComment
%endIf%
%DDLScriptSeparator%
3、找到脚本DLL column Definition, 完整修改代码如下
%PI=" "%
%DDLName("EA", "COLUMN", "", "INCLUDE_SURROUND")%
%DDLDataType%
$Type = %columnProperty:"TYPE"%
$Default = %columnProperty:"DEFAULT"%
$Find = ""
%if $Type != "ENUM" and $Type != "SET"%
%if $Default != ""%
$Find = %FIND($Default, "DEFAULT")%
%if $Find == "0"%
$Default = "DEFAULT " + $Default
%endIf%
%endIf%
%endIf%
%if columnBoolProperty:"ZEROFILL" == "T"%
ZEROFILL
%endIf%
%if columnBoolProperty:"UNSIGNED" == "T"%
UNSIGNED
%endIf%
%if columnBoolProperty:"NULLABLE" == "T"%
%if ddlOptionGenerateNullable == "T"%
NULL
%endIf%
%else%
NOT NULL
%endIf%
%if columnBoolProperty:"AutoNum" == "T"%
AUTO_INCREMENT
%else%
%if $Default != ""%
DEFAULT $Default
%endIf%
%endIf%
%DDLColumnComment%
%PI("I", "")%
,
总结:如果你更好的解决方案,特别是我发现的第2个问题,请反馈给我ninja911#qq.com,谢谢!
分类:
PHP之路
标签:
模型ArchitectEnterprise数据库
版权申明
本文系作者 @ninja911 原创发布在NinJa911 Blog站点。未经许可,禁止转载。
全部评论 1
rantrism
Google Chrome Linux您好~我是腾讯云开发者社区运营,关注了您分享的技术文章,觉得内容很棒,我们诚挚邀请您加入腾讯云自媒体分享计划。完整福利和申请地址请见:https://cloud.tencent.com/developer/support-plan
作者申请此计划后将作者的文章进行搬迁同步到社区的专栏下,你只需要简单填写一下表单申请即可,我们会给作者提供包括流量、云服务器等,另外还有些周边礼物。