提交 223e94d6 编写于 作者: J jurgen

DDL generation fix

上级 8e903cb0
......@@ -200,7 +200,7 @@ public abstract class NavigatorHandlerObjectBase extends AbstractHandler {
Collection<? extends DBECommand> commands = commandContext.getFinalCommands();
StringBuilder script = new StringBuilder();
for (DBECommand command : commands) {
script.append(DBUtils.generateScript(command.getPersistActions()));
script.append(DBUtils.generateScript(command.getPersistActions(), false));
}
DatabaseNavigatorView view = UIUtils.findView(workbenchWindow, DatabaseNavigatorView.class);
if (view != null) {
......
......@@ -19,7 +19,6 @@ package org.jkiss.dbeaver.ui.editors.entity;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
......@@ -65,7 +64,6 @@ import org.jkiss.dbeaver.ui.editors.DatabaseEditorInput;
import org.jkiss.dbeaver.ui.editors.ErrorEditorInput;
import org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput;
import org.jkiss.dbeaver.ui.editors.MultiPageDatabaseEditor;
import org.jkiss.dbeaver.ui.navigator.INavigatorModelView;
import org.jkiss.utils.CommonUtils;
import java.lang.reflect.InvocationTargetException;
......@@ -347,7 +345,7 @@ public class EntityEditor extends MultiPageDatabaseEditor
return IDialogConstants.CANCEL_ID;
}
script.append(DBUtils.generateScript(
command.getPersistActions()));
command.getPersistActions(), false));
}
ChangesPreviewer changesPreviewer = new ChangesPreviewer(script, allowSave);
......
......@@ -237,7 +237,7 @@ public class GenericMetaModel {
public String getTableDDL(DBRProgressMonitor monitor, GenericTable sourceObject) throws DBException {
GenericTableManager tableManager = new GenericTableManager();
DBEPersistAction[] ddlActions = tableManager.getTableDDL(monitor, sourceObject);
return DBUtils.generateScript(ddlActions);
return DBUtils.generateScript(ddlActions, true);
}
public String getProcedureDDL(DBRProgressMonitor monitor, GenericProcedure sourceObject) throws DBException {
......
......@@ -1107,12 +1107,14 @@ public final class DBUtils {
}
@NotNull
public static String generateScript(DBEPersistAction[] persistActions)
public static String generateScript(DBEPersistAction[] persistActions, boolean existingObject)
{
String lineSeparator = GeneralUtils.getDefaultLineSeparator();
StringBuilder script = new StringBuilder(64);
script.append(DBEAVER_DDL_COMMENT).append(Platform.getProduct().getName()).append(lineSeparator)
.append(DBEAVER_DDL_WARNING).append(lineSeparator);
if (existingObject) {
script.append(DBEAVER_DDL_COMMENT).append(Platform.getProduct().getName()).append(lineSeparator)
.append(DBEAVER_DDL_WARNING).append(lineSeparator);
}
for (DBEPersistAction action : ArrayUtils.safeArray(persistActions)) {
String scriptLine = action.getScript();
if (CommonUtils.isEmpty(scriptLine)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册