use of org.jkiss.dbeaver.ext.postgresql.edit.PostgreViewManager in project dbeaver by serge-rider.
the class PostgreUtils method getViewDDL.
public static String getViewDDL(DBRProgressMonitor monitor, PostgreViewBase view, String definition) throws DBException {
// In some cases view definition already has view header (e.g. Redshift + with no schema binding)
if (definition.toLowerCase(Locale.ENGLISH).startsWith("create ")) {
return definition;
}
StringBuilder sql = new StringBuilder(view instanceof PostgreView ? "CREATE OR REPLACE " : "CREATE ");
sql.append(view.getViewType()).append(" ").append(view.getFullyQualifiedName(DBPEvaluationContext.DDL));
final DBERegistry editorsRegistry = view.getDataSource().getContainer().getPlatform().getEditorsRegistry();
final PostgreViewManager entityEditor = editorsRegistry.getObjectManager(view.getClass(), PostgreViewManager.class);
if (entityEditor != null) {
entityEditor.appendViewDeclarationPrefix(monitor, sql, view);
}
definition = definition.trim();
while (definition.endsWith(";")) {
definition = definition.substring(0, definition.length() - 1);
}
sql.append("\nAS ").append(definition);
if (entityEditor != null) {
entityEditor.appendViewDeclarationPostfix(monitor, sql, view);
}
sql.append(";");
return sql.toString();
}
use of org.jkiss.dbeaver.ext.postgresql.edit.PostgreViewManager in project dbeaver by dbeaver.
the class PostgreUtils method getViewDDL.
public static String getViewDDL(DBRProgressMonitor monitor, PostgreViewBase view, String definition) throws DBException {
// In some cases view definition already has view header (e.g. Redshift + with no schema binding)
if (definition.toLowerCase(Locale.ENGLISH).startsWith("create ")) {
return definition;
}
StringBuilder sql = new StringBuilder(view instanceof PostgreView ? "CREATE OR REPLACE " : "CREATE ");
sql.append(view.getViewType()).append(" ").append(view.getFullyQualifiedName(DBPEvaluationContext.DDL));
final DBERegistry editorsRegistry = view.getDataSource().getContainer().getPlatform().getEditorsRegistry();
final PostgreViewManager entityEditor = editorsRegistry.getObjectManager(view.getClass(), PostgreViewManager.class);
if (entityEditor != null) {
entityEditor.appendViewDeclarationPrefix(monitor, sql, view);
}
definition = definition.trim();
while (definition.endsWith(";")) {
definition = definition.substring(0, definition.length() - 1);
}
sql.append("\nAS ").append(definition);
if (entityEditor != null) {
entityEditor.appendViewDeclarationPostfix(monitor, sql, view);
}
sql.append(";");
return sql.toString();
}
Aggregations