Skip to content

Commit

Permalink
[TOOLS-4552] Incorrect query generation when creating a view without …
Browse files Browse the repository at this point in the history
  • Loading branch information
Srltas authored Feb 23, 2024
1 parent fceda9c commit 2452915
Showing 1 changed file with 13 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -613,54 +613,25 @@ public String getViewDDL(View view, boolean addUserSchema) {
sb.append(getOwnerNameWithDot(view.getOwner(), addUserSchema));
sb.append(getQuotedObjName(viewName));

// Column definitions are not necessarily.
// sb.append("(");
// List<Column> list = view.getColumns();
//
// for (Iterator<Column> iterator = list.iterator(); iterator.hasNext();) {
// Column column = (Column) iterator.next();
//
// String type = column.getShownDataType();
// sb.append(NEWLINE).append(" ").append(
// getDBQualifier(column.getName())).append(" ").append(type);
// String defaultv = column.getDefaultValue();
//
// if (defaultv != null) {
// defaultv = CUBRIDFormator.formatValue(column.getDataType(),
// column.getSubDataType(), column.getScale(), defaultv).getFormatResult();
//
// if (defaultv != null) {
// sb.append(" DEFAULT ").append(defaultv);
// }
// }
//
// sb.append(",");
// }
//
// if (!list.isEmpty() && sb.length() > 0) {
// sb.deleteCharAt(sb.length() - 1);
// }
//
// sb.append(")").append(NEWLINE);

List<Column> columnList = view.getColumns();
if (!columnList.isEmpty()) {
sb.append("(").append(NEWLINE);
for (int i = 0; i < columnList.size(); i++) {
Column col = columnList.get(i);

sb.append("(").append(NEWLINE);
for (int i = 0; i < columnList.size(); i++) {
Column col = columnList.get(i);

if (i > 0) {
sb.append(",").append(NEWLINE);
}
if (i > 0) {
sb.append(",").append(NEWLINE);
}

sb.append(getQuotedObjName(col.getName()));
sb.append(" ").append(col.getShownDataType());
sb.append(getQuotedObjName(col.getName()));
sb.append(" ").append(col.getShownDataType());

if (col.getComment() != null) {
sb.append(" COMMENT ").append(col.getComment());
if (col.getComment() != null) {
sb.append(" COMMENT ").append(col.getComment());
}
}
sb.append(NEWLINE).append(")");
}
sb.append(NEWLINE).append(")");

if (view.getComment() != null) {
sb.append(" ").append("COMMENT \'" + view.getComment() + "\'");
Expand Down

0 comments on commit 2452915

Please sign in to comment.