提交 b55500e7 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add ConstraintActionType.getSqlName()

上级 4dd2d02c
...@@ -24,5 +24,21 @@ public enum ConstraintActionType { ...@@ -24,5 +24,21 @@ public enum ConstraintActionType {
/** /**
* The action is to set the value to NULL. * The action is to set the value to NULL.
*/ */
SET_NULL SET_NULL;
/**
* Get standard SQL type name.
*
* @return standard SQL type name
*/
public String getSqlName() {
if (this == ConstraintActionType.SET_DEFAULT) {
return "SET DEFAULT";
}
if (this == SET_NULL) {
return "SET NULL";
}
return name();
}
} }
\ No newline at end of file
...@@ -54,22 +54,6 @@ public class ConstraintReferential extends Constraint { ...@@ -54,22 +54,6 @@ public class ConstraintReferential extends Constraint {
return Constraint.Type.REFERENTIAL; return Constraint.Type.REFERENTIAL;
} }
private static void appendAction(StatementBuilder buff, ConstraintActionType action) {
switch (action) {
case CASCADE:
buff.append("CASCADE");
break;
case SET_DEFAULT:
buff.append("SET DEFAULT");
break;
case SET_NULL:
buff.append("SET NULL");
break;
default:
DbException.throwInternalError("action=" + action);
}
}
/** /**
* Create the SQL statement of this object so a copy of the table can be * Create the SQL statement of this object so a copy of the table can be
* made. * made.
...@@ -135,12 +119,10 @@ public class ConstraintReferential extends Constraint { ...@@ -135,12 +119,10 @@ public class ConstraintReferential extends Constraint {
buff.append(" INDEX ").append(refIndex.getSQL()); buff.append(" INDEX ").append(refIndex.getSQL());
} }
if (deleteAction != ConstraintActionType.RESTRICT) { if (deleteAction != ConstraintActionType.RESTRICT) {
buff.append(" ON DELETE "); buff.append(" ON DELETE ").append(deleteAction.getSqlName());
appendAction(buff, deleteAction);
} }
if (updateAction != ConstraintActionType.RESTRICT) { if (updateAction != ConstraintActionType.RESTRICT) {
buff.append(" ON UPDATE "); buff.append(" ON UPDATE ").append(updateAction.getSqlName());
appendAction(buff, updateAction);
} }
return buff.append(" NOCHECK").toString(); return buff.append(" NOCHECK").toString();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论