[#7484] Add DSLContext.selectFrom(Name) and selectFrom(String) overloads

This commit is contained in:
lukaseder 2018-05-14 09:40:31 +02:00
parent 65c6222253
commit 213ba8d311
5 changed files with 368 additions and 0 deletions

View File

@ -5518,6 +5518,93 @@ public interface DSLContext extends Scope , AutoCloseable {
@Support
<R extends Record> SelectWhereStep<R> selectFrom(Table<R> table);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
*
* @see DSL#table(Name)
*/
@Support
<R extends Record> SelectWhereStep<R> selectFrom(Name table);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(SQL)
* @see SQL
*/
@Support
<R extends Record> SelectWhereStep<R> selectFrom(SQL sql);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
* @see DSL#sql(String)
* @see SQL
*/
@Support
<R extends Record> SelectWhereStep<R> selectFrom(String sql);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support
<R extends Record> SelectWhereStep<R> selectFrom(String sql, Object... bindings);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support
<R extends Record> SelectWhereStep<R> selectFrom(String sql, QueryPart... parts);
/**
* Create a new DSL select statement.
* <p>

View File

@ -484,6 +484,93 @@ public interface WithStep extends QueryPart {
@Support({ FIREBIRD, H2, HSQLDB, MYSQL_8_0, POSTGRES })
<R extends Record> SelectWhereStep<R> selectFrom(Table<R> table);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
*
* @see DSL#table(Name)
*/
@Support({ FIREBIRD, H2, HSQLDB, MYSQL_8_0, POSTGRES })
<R extends Record> SelectWhereStep<R> selectFrom(Name table);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(SQL)
* @see SQL
*/
@Support({ FIREBIRD, H2, HSQLDB, MYSQL_8_0, POSTGRES })
<R extends Record> SelectWhereStep<R> selectFrom(SQL sql);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
* @see DSL#sql(String)
* @see SQL
*/
@Support({ FIREBIRD, H2, HSQLDB, MYSQL_8_0, POSTGRES })
<R extends Record> SelectWhereStep<R> selectFrom(String sql);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support({ FIREBIRD, H2, HSQLDB, MYSQL_8_0, POSTGRES })
<R extends Record> SelectWhereStep<R> selectFrom(String sql, Object... bindings);
/**
* Create a new DSL select statement.
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support({ FIREBIRD, H2, HSQLDB, MYSQL_8_0, POSTGRES })
<R extends Record> SelectWhereStep<R> selectFrom(String sql, QueryPart... parts);
/**
* Create a new DSL select statement.
* <p>

View File

@ -2647,6 +2647,148 @@ public class DSL {
return dsl().selectFrom(table);
}
/**
* Create a new DSL select statement.
* <p>
* Unlike {@link Select} factory methods in the {@link DSLContext} API, this
* creates an unattached, and thus not directly renderable or executable
* <code>SELECT</code> statement. You can use this statement in two ways:
* <ul>
* <li>As a subselect within another select</li>
* <li>As a statement, after attaching it using
* {@link Select#attach(org.jooq.Configuration)}</li>
* </ul>
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
*
* @see DSL#table(Name)
*/
@Support
public static <R extends Record> SelectWhereStep<R> selectFrom(Name table) {
return dsl().selectFrom(table);
}
/**
* Create a new DSL select statement.
* <p>
* Unlike {@link Select} factory methods in the {@link DSLContext} API, this
* creates an unattached, and thus not directly renderable or executable
* <code>SELECT</code> statement. You can use this statement in two ways:
* <ul>
* <li>As a subselect within another select</li>
* <li>As a statement, after attaching it using
* {@link Select#attach(org.jooq.Configuration)}</li>
* </ul>
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(SQL)
* @see SQL
*/
@Support
public static <R extends Record> SelectWhereStep<R> selectFrom(SQL sql) {
return dsl().selectFrom(sql);
}
/**
* Create a new DSL select statement.
* <p>
* Unlike {@link Select} factory methods in the {@link DSLContext} API, this
* creates an unattached, and thus not directly renderable or executable
* <code>SELECT</code> statement. You can use this statement in two ways:
* <ul>
* <li>As a subselect within another select</li>
* <li>As a statement, after attaching it using
* {@link Select#attach(org.jooq.Configuration)}</li>
* </ul>
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
* @see DSL#sql(String)
* @see SQL
*/
@Support
public static <R extends Record> SelectWhereStep<R> selectFrom(String sql) {
return dsl().selectFrom(sql);
}
/**
* Create a new DSL select statement.
* <p>
* Unlike {@link Select} factory methods in the {@link DSLContext} API, this
* creates an unattached, and thus not directly renderable or executable
* <code>SELECT</code> statement. You can use this statement in two ways:
* <ul>
* <li>As a subselect within another select</li>
* <li>As a statement, after attaching it using
* {@link Select#attach(org.jooq.Configuration)}</li>
* </ul>
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support
public static <R extends Record> SelectWhereStep<R> selectFrom(String sql, Object... bindings) {
return dsl().selectFrom(sql, bindings);
}
/**
* Create a new DSL select statement.
* <p>
* Unlike {@link Select} factory methods in the {@link DSLContext} API, this
* creates an unattached, and thus not directly renderable or executable
* <code>SELECT</code> statement. You can use this statement in two ways:
* <ul>
* <li>As a subselect within another select</li>
* <li>As a statement, after attaching it using
* {@link Select#attach(org.jooq.Configuration)}</li>
* </ul>
* <p>
* Example: <code><pre>
* SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
* </pre></code>
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support
public static <R extends Record> SelectWhereStep<R> selectFrom(String sql, QueryPart... parts) {
return dsl().selectFrom(sql, parts);
}
/**
* Create a new DSL subselect statement.
* <p>

View File

@ -2115,6 +2115,31 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new SelectImpl(configuration(), null).from(table);
}
@Override
public <R extends Record> SelectWhereStep<R> selectFrom(Name table) {
return new SelectImpl(configuration(), null).from(table);
}
@Override
public <R extends Record> SelectWhereStep<R> selectFrom(SQL sql) {
return new SelectImpl(configuration(), null).from(sql);
}
@Override
public <R extends Record> SelectWhereStep<R> selectFrom(String sql) {
return new SelectImpl(configuration(), null).from(sql);
}
@Override
public <R extends Record> SelectWhereStep<R> selectFrom(String sql, Object... bindings) {
return new SelectImpl(configuration(), null).from(sql, bindings);
}
@Override
public <R extends Record> SelectWhereStep<R> selectFrom(String sql, QueryPart... parts) {
return new SelectImpl(configuration(), null).from(sql, parts);
}
@Override
public SelectSelectStep<Record> select(Collection<? extends SelectFieldOrAsterisk> fields) {
return new SelectImpl(configuration(), null).select(fields);

View File

@ -64,6 +64,7 @@ import org.jooq.Field;
import org.jooq.InsertSetStep;
import org.jooq.MergeUsingStep;
import org.jooq.Name;
import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Record10;
@ -87,6 +88,7 @@ import org.jooq.Record6;
import org.jooq.Record7;
import org.jooq.Record8;
import org.jooq.Record9;
import org.jooq.SQL;
import org.jooq.SQLDialect;
import org.jooq.Select;
import org.jooq.SelectField;
@ -514,6 +516,31 @@ implements
return new SelectImpl(configuration, this).from(table);
}
@Override
public final <R extends Record> SelectWhereStep<R> selectFrom(Name table) {
return new SelectImpl(configuration, this).from(table);
}
@Override
public final <R extends Record> SelectWhereStep<R> selectFrom(SQL sql) {
return new SelectImpl(configuration, this).from(sql);
}
@Override
public final <R extends Record> SelectWhereStep<R> selectFrom(String sql) {
return new SelectImpl(configuration, this).from(sql);
}
@Override
public final <R extends Record> SelectWhereStep<R> selectFrom(String sql, Object... bindings) {
return new SelectImpl(configuration, this).from(sql, bindings);
}
@Override
public final <R extends Record> SelectWhereStep<R> selectFrom(String sql, QueryPart... parts) {
return new SelectImpl(configuration, this).from(sql, parts);
}
@Override
public final SelectSelectStep<Record> select(Collection<? extends SelectFieldOrAsterisk> fields) {
return new SelectImpl(configuration, this).select(fields);