[jOOQ/jOOQ#9994] Add missing with(Collection<? extends CommonTableExpression<?>>) overloads

This commit is contained in:
Lukas Eder 2020-03-26 16:24:57 +01:00
parent 8fba879f62
commit b3d89c846b
5 changed files with 314 additions and 0 deletions

View File

@ -3899,6 +3899,22 @@ public interface DSLContext extends Scope , AutoCloseable {
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep with(String alias, String... fieldAliases);
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(String, String...)} for strictly non-recursive CTE
* and {@link #withRecursive(String, String...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep with(String alias, Collection<String> fieldAliases);
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
@ -3931,6 +3947,22 @@ public interface DSLContext extends Scope , AutoCloseable {
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep with(Name alias, Name... fieldAliases);
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(Name, Name...)} for strictly non-recursive CTE
* and {@link #withRecursive(Name, Name...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep with(Name alias, Collection<? extends Name> fieldAliases);
/**
* Create a <code>WITH</code> clause to supply subsequent
@ -4703,6 +4735,30 @@ public interface DSLContext extends Scope , AutoCloseable {
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithStep with(CommonTableExpression<?>... tables);
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* Reusable {@link CommonTableExpression} types can be constructed through
* <ul>
* <li>{@link DSL#name(String...)}</li>
* <li>{@link Name#fields(String...)}</li>
* <li>
* {@link DerivedColumnList#as(Select)}</li>
* </ul>
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(CommonTableExpression...)} for strictly non-recursive CTE
* and {@link #withRecursive(CommonTableExpression...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithStep with(Collection<? extends CommonTableExpression<?>> tables);
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
@ -4735,6 +4791,22 @@ public interface DSLContext extends Scope , AutoCloseable {
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep withRecursive(String alias, String... fieldAliases);
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(String, String...)} for strictly non-recursive CTE
* and {@link #withRecursive(String, String...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep withRecursive(String alias, Collection<String> fieldAliases);
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
@ -4767,6 +4839,22 @@ public interface DSLContext extends Scope , AutoCloseable {
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep withRecursive(Name alias, Name... fieldAliases);
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(Name, Name...)} for strictly non-recursive CTE
* and {@link #withRecursive(Name, Name...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep withRecursive(Name alias, Collection<? extends Name> fieldAliases);
/**
* Create a <code>WITH</code> clause to supply subsequent
@ -5541,6 +5629,30 @@ public interface DSLContext extends Scope , AutoCloseable {
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithStep withRecursive(CommonTableExpression<?>... tables);
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* Reusable {@link CommonTableExpression} types can be constructed through
* <ul>
* <li>{@link DSL#name(String...)}</li>
* <li>{@link Name#fields(String...)}</li>
* <li>
* {@link DerivedColumnList#as(Select)}</li>
* </ul>
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(CommonTableExpression...)} for strictly non-recursive CTE
* and {@link #withRecursive(CommonTableExpression...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithStep withRecursive(Collection<? extends CommonTableExpression<?>> tables);
/**
* Create a new DSL select statement, projecting the known columns from a
* table.

View File

@ -115,6 +115,12 @@ public interface WithStep extends QueryPart {
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep with(String alias, String... fieldAliases);
/**
* Add another common table expression to the <code>WITH</code> clause.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep with(String alias, Collection<String> fieldAliases);
/**
* Add another common table expression to the <code>WITH</code> clause.
*/
@ -127,6 +133,12 @@ public interface WithStep extends QueryPart {
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep with(Name alias, Name... fieldAliases);
/**
* Add another common table expression to the <code>WITH</code> clause.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithAsStep with(Name alias, Collection<? extends Name> fieldAliases);
/**
* Add another common table expression to the <code>WITH</code> clause.
@ -431,6 +443,20 @@ public interface WithStep extends QueryPart {
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithStep with(CommonTableExpression<?>... tables);
/**
* Add another common table expression to the <code>WITH</code> clause.
* <p>
* Reusable {@link CommonTableExpression} types can be constructed through
* <ul>
* <li>{@link DSL#name(String...)}</li>
* <li>{@link Name#fields(String...)}</li>
* <li>
* {@link DerivedColumnList#as(Select)}</li>
* </ul>
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
WithStep with(Collection<? extends CommonTableExpression<?>> tables);
// -------------------------------------------------------------------------
// XXX Continue with the actual INSERT, UPDATE, DELETE, SELECT statement type
// -------------------------------------------------------------------------

View File

@ -776,6 +776,24 @@ public class DSL {
return new WithImpl(null, false).with(alias, fieldAliases);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(String, String...)} for strictly non-recursive CTE
* and {@link #withRecursive(String, String...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static WithAsStep with(String alias, Collection<String> fieldAliases) {
return new WithImpl(null, false).with(alias, fieldAliases);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
@ -812,6 +830,24 @@ public class DSL {
return new WithImpl(null, false).with(alias, fieldAliases);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(Name, Name...)} for strictly non-recursive CTE
* and {@link #withRecursive(Name, Name...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static WithAsStep with(Name alias, Collection<? extends Name> fieldAliases) {
return new WithImpl(null, false).with(alias, fieldAliases);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
@ -1657,6 +1693,32 @@ public class DSL {
return new WithImpl(null, false).with(tables);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* Reusable {@link CommonTableExpression} types can be constructed through
* <ul>
* <li>{@link #name(String...)}</li>
* <li>{@link Name#fields(String...)}</li>
* <li>
* {@link DerivedColumnList#as(Select)}</li>
* </ul>
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(CommonTableExpression...)} for strictly non-recursive CTE
* and {@link #withRecursive(CommonTableExpression...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static WithStep with(Collection<? extends CommonTableExpression<?>> tables) {
return new WithImpl(null, false).with(tables);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
@ -1699,6 +1761,27 @@ public class DSL {
return new WithImpl(null, true).with(alias, fieldAliases);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(String, String...)} for strictly non-recursive CTE
* and {@link #withRecursive(String, String...)} for strictly
* recursive CTE.
* <p>
* Note that the {@link SQLDialect#H2} database only supports single-table,
* <code>RECURSIVE</code> common table expression lists.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static WithAsStep withRecursive(String alias, Collection<String> fieldAliases) {
return new WithImpl(null, true).with(alias, fieldAliases);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
@ -1738,6 +1821,24 @@ public class DSL {
return new WithImpl(null, true).with(alias, fieldAliases);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(Name, Name...)} for strictly non-recursive CTE
* and {@link #withRecursive(Name, Name...)} for strictly
* recursive CTE.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static WithAsStep withRecursive(Name alias, Collection<? extends Name> fieldAliases) {
return new WithImpl(null, true).with(alias, fieldAliases);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
@ -2590,6 +2691,35 @@ public class DSL {
return new WithImpl(null, true).with(tables);
}
/**
* Create a <code>WITH</code> clause to supply subsequent
* <code>SELECT</code>, <code>UPDATE</code>, <code>INSERT</code>,
* <code>DELETE</code>, and <code>MERGE</code> statements with
* {@link CommonTableExpression}s.
* <p>
* Reusable {@link CommonTableExpression} types can be constructed through
* <ul>
* <li>{@link #name(String...)}</li>
* <li>{@link Name#fields(String...)}</li>
* <li>
* {@link DerivedColumnList#as(Select)}</li>
* </ul>
* <p>
* The <code>RECURSIVE</code> keyword may be optional or unsupported in some
* databases, in case of which it will not be rendered. For optimal database
* interoperability and readability, however, it is suggested that you use
* {@link #with(CommonTableExpression...)} for strictly non-recursive CTE
* and {@link #withRecursive(CommonTableExpression...)} for strictly
* recursive CTE.
* <p>
* Note that the {@link SQLDialect#H2} database only supports single-table,
* <code>RECURSIVE</code> common table expression lists.
*/
@Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static WithStep withRecursive(Collection<? extends CommonTableExpression<?>> tables) {
return new WithImpl(null, true).with(tables);
}
/**
* Create a new DSL select statement, projecting the known columns from a
* table.

View File

@ -1592,6 +1592,11 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new WithImpl(configuration(), false).with(alias, fieldAliases);
}
@Override
public WithAsStep with(String alias, Collection<String> fieldAliases) {
return new WithImpl(configuration(), false).with(alias, fieldAliases);
}
@Override
public WithAsStep with(Name alias) {
return new WithImpl(configuration(), false).with(alias);
@ -1602,6 +1607,11 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new WithImpl(configuration(), false).with(alias, fieldAliases);
}
@Override
public WithAsStep with(Name alias, Collection<? extends Name> fieldAliases) {
return new WithImpl(configuration(), false).with(alias, fieldAliases);
}
@Override
public WithAsStep with(String alias, Function<? super Field<?>, ? extends String> fieldNameFunction) {
@ -1843,6 +1853,11 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new WithImpl(configuration(), false).with(tables);
}
@Override
public WithStep with(Collection<? extends CommonTableExpression<?>> tables) {
return new WithImpl(configuration(), false).with(tables);
}
@Override
public WithAsStep withRecursive(String alias) {
return new WithImpl(configuration(), true).with(alias);
@ -1853,6 +1868,11 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new WithImpl(configuration(), true).with(alias, fieldAliases);
}
@Override
public WithAsStep withRecursive(String alias, Collection<String> fieldAliases) {
return new WithImpl(configuration(), true).with(alias, fieldAliases);
}
@Override
public WithAsStep withRecursive(Name alias) {
return new WithImpl(configuration(), true).with(alias);
@ -1863,6 +1883,11 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new WithImpl(configuration(), true).with(alias, fieldAliases);
}
@Override
public WithAsStep withRecursive(Name alias, Collection<? extends Name> fieldAliases) {
return new WithImpl(configuration(), true).with(alias, fieldAliases);
}
@Override
public WithAsStep withRecursive(String alias, Function<? super Field<?>, ? extends String> fieldNameFunction) {
@ -2104,6 +2129,11 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new WithImpl(configuration(), true).with(tables);
}
@Override
public WithStep withRecursive(Collection<? extends CommonTableExpression<?>> tables) {
return new WithImpl(configuration(), true).with(tables);
}
@Override
public <R extends Record> SelectWhereStep<R> selectFrom(Table<R> table) {
return new SelectImpl(configuration(), null).from(table);

View File

@ -48,6 +48,7 @@ import static org.jooq.impl.DSL.one;
import static org.jooq.impl.DSL.zero;
import static org.jooq.impl.Keywords.K_RECURSIVE;
import static org.jooq.impl.Keywords.K_WITH;
import static org.jooq.impl.Tools.EMPTY_NAME;
import java.util.Arrays;
import java.util.Collection;
@ -262,6 +263,11 @@ implements
return with(DSL.name(a), Tools.names(f));
}
@Override
public final WithImpl with(String a, Collection<String> f) {
return with(DSL.name(a), Tools.names(f));
}
@Override
public final WithImpl with(Name a) {
return with(a, new Name[0]);
@ -275,6 +281,11 @@ implements
return this;
}
@Override
public final WithImpl with(Name a, Collection<? extends Name> f) {
return with(a, f.toArray(EMPTY_NAME));
}
@Override
public final WithImpl with(String a, Function<? super Field<?>, ? extends String> f) {
@ -519,6 +530,11 @@ implements
@Override
public final WithStep with(CommonTableExpression<?>... tables) {
return with(Arrays.asList(tables));
}
@Override
public final WithStep with(Collection<? extends CommonTableExpression<?>> tables) {
for (CommonTableExpression<?> table : tables)
cte.add(table);