diff --git a/jOOQ/src/main/java/org/jooq/AlterViewAsStep.java b/jOOQ/src/main/java/org/jooq/AlterViewAsStep.java
deleted file mode 100644
index 53983536f9..0000000000
--- a/jOOQ/src/main/java/org/jooq/AlterViewAsStep.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Other licenses:
- * -----------------------------------------------------------------------------
- * Commercial licenses for this work are available. These replace the above
- * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
- * database integrations.
- *
- * For more information, please visit: https://www.jooq.org/legal/licensing
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- */
-package org.jooq;
-
-import static org.jooq.SQLDialect.*;
-import static org.jooq.impl.DSL.*;
-
-import java.util.*;
-
-import org.jooq.impl.DSL;
-
-import org.jetbrains.annotations.*;
-
-/**
- * A step in the construction of the ALTER VIEW statement.
- *
- *
XYZ*Step types directly from client code
- * It is usually not recommended to reference any XYZ*Step types
- * directly from client code, or assign them to local variables. When writing
- * dynamic SQL, creating a statement's components dynamically, and passing them
- * to the DSL API statically is usually a better choice. See the manual's
- * section about dynamic SQL for details: https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql.
- *
- * Drawbacks of referencing the XYZ*Step types directly:
- *
AS clause to the ALTER VIEW statement.
- */
- @Support({ FIREBIRD, H2, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
- @NotNull @CheckReturnValue
- AlterViewFinalStep as(Select> as);
-}
diff --git a/jOOQ/src/main/java/org/jooq/AlterViewStep.java b/jOOQ/src/main/java/org/jooq/AlterViewStep.java
index 9b90590266..ac880e8beb 100644
--- a/jOOQ/src/main/java/org/jooq/AlterViewStep.java
+++ b/jOOQ/src/main/java/org/jooq/AlterViewStep.java
@@ -68,7 +68,7 @@ import org.jetbrains.annotations.*;
*
*/
@SuppressWarnings({ "unused" })
-public interface AlterViewStep extends AlterViewAsStep {
+public interface AlterViewStep {
/**
* Add the COMMENT clause to the ALTER VIEW statement.
@@ -104,4 +104,11 @@ public interface AlterViewStep extends AlterViewAsStep {
@Support({ H2, HSQLDB, POSTGRES, YUGABYTEDB })
@NotNull @CheckReturnValue
AlterViewFinalStep renameTo(Table> renameTo);
+
+ /**
+ * Add the AS clause to the ALTER VIEW statement.
+ */
+ @Support({ FIREBIRD, H2, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
+ @NotNull @CheckReturnValue
+ AlterViewFinalStep as(Select> as);
}
diff --git a/jOOQ/src/main/java/org/jooq/DSLContext.java b/jOOQ/src/main/java/org/jooq/DSLContext.java
index 7e3a24dc84..d88b8a4a65 100644
--- a/jOOQ/src/main/java/org/jooq/DSLContext.java
+++ b/jOOQ/src/main/java/org/jooq/DSLContext.java
@@ -9633,7 +9633,7 @@ public interface DSLContext extends Scope {
*/
@NotNull @CheckReturnValue
@Support({ FIREBIRD, H2, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
- AlterViewAsStep alterView(Table> view, Field>... fields);
+ AlterViewStep alterView(Table> view, Field>... fields);
/**
* The ALTER VIEW statement.
@@ -9642,7 +9642,7 @@ public interface DSLContext extends Scope {
*/
@NotNull @CheckReturnValue
@Support({ FIREBIRD, H2, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
- AlterViewAsStep alterView(Table> view, Collection extends Field>> fields);
+ AlterViewStep alterView(Table> view, Collection extends Field>> fields);
/**
* The COMMENT ON TABLE statement.
diff --git a/jOOQ/src/main/java/org/jooq/impl/AlterViewImpl.java b/jOOQ/src/main/java/org/jooq/impl/AlterViewImpl.java
index 2d1853c6db..263ee51ff6 100644
--- a/jOOQ/src/main/java/org/jooq/impl/AlterViewImpl.java
+++ b/jOOQ/src/main/java/org/jooq/impl/AlterViewImpl.java
@@ -71,7 +71,6 @@ extends
implements
QOM.AlterView,
AlterViewStep,
- AlterViewAsStep,
AlterViewFinalStep
{
diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java
index 6d5b4b6d72..46dd9055b1 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DSL.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java
@@ -7714,7 +7714,7 @@ public class DSL {
*/
@NotNull @CheckReturnValue
@Support({ FIREBIRD, H2, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
- public static org.jooq.AlterViewAsStep alterView(Table> view, Field>... fields) {
+ public static org.jooq.AlterViewStep alterView(Table> view, Field>... fields) {
return dsl().alterView(view, fields);
}
@@ -7729,7 +7729,7 @@ public class DSL {
*/
@NotNull @CheckReturnValue
@Support({ FIREBIRD, H2, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
- public static org.jooq.AlterViewAsStep alterView(Table> view, Collection extends Field>> fields) {
+ public static org.jooq.AlterViewStep alterView(Table> view, Collection extends Field>> fields) {
return dsl().alterView(view, fields);
}
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java
index b3d5e48341..f7d7c40347 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java
@@ -3054,12 +3054,12 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
}
@Override
- public org.jooq.AlterViewAsStep alterView(Table> view, Field>... fields) {
+ public org.jooq.AlterViewStep alterView(Table> view, Field>... fields) {
return new AlterViewImpl(configuration(), view, Arrays.asList(fields), false);
}
@Override
- public org.jooq.AlterViewAsStep alterView(Table> view, Collection extends Field>> fields) {
+ public org.jooq.AlterViewStep alterView(Table> view, Collection extends Field>> fields) {
return new AlterViewImpl(configuration(), view, new QueryPartList<>(fields), false);
}
diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java
index 46c47ad184..02caafa586 100644
--- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java
+++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java
@@ -4219,8 +4219,28 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
private final DDLQuery parseAlterView() {
boolean ifExists = parseKeywordIf("IF EXISTS");
Table> oldName = parseTableName();
+ Field>[] fields = EMPTY_FIELD;
- if (parseKeywordIf("RENAME")) {
+ if (parseIf('(')) {
+ fields = parseList(',', c -> parseFieldName()).toArray(fields);
+ parse(')');
+ }
+
+ if (parseKeywordIf("AS")) {
+ Select> select = parseWithOrSelect();
+ int degree = Tools.degree(select);
+
+ if (fields.length > 0 && fields.length != degree)
+ throw exception("Select list size (" + degree + ") must match declared field size (" + fields.length + ")");
+
+ if (fields.length == 0)
+ return dsl.alterView(oldName).as(select);
+ else
+ return dsl.alterView(oldName, fields).as(select);
+ }
+ else if (fields.length > 0)
+ throw expected("AS");
+ else if (parseKeywordIf("RENAME")) {
parseKeyword("AS", "TO");
Table> newName = parseTableName();
@@ -4233,7 +4253,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if (parseKeywordIf("SET"))
return dsl.alterView(oldName).comment(parseOptionsDescription());
else
- throw expected("OWNER TO", "RENAME", "SET");
+ throw expected("AS", "OWNER TO", "RENAME", "SET");
}
private final Comment parseOptionsDescription() {